Commit 58257ea2 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge remote-tracking branch 'qatar/master'

* qatar/master: (28 commits)
  mp3enc: write a xing frame containing number of frames in the file
  lavf: update AVStream.nb_frames when muxing.
  ffmpeg: remove unused variables from InputStream.
  doc: update ffmpeg -ar and -ac documentation to reflect reality.
  ffmpeg: remove pointless if (nb_input_files)
  ffmpeg: merge input_files_ts_offset into input_files.
  ffmpeg: merge input_codecs into input_streams.
  ffmpeg: drop AV prefixes from struct names.
  ffmpeg: deprecate loop_input and loop_output options
  gif: add loop private option.
  img2: add loop private option.
  AVOptions: in av_opt_find() don't return named constants unless unit is specified.
  x11grab: replace undocumented nomouse hackery with a private option.
  dict: extend documentation.
  lls: whitespace cosmetics
  docs: Use proper markup for a literal command line option
  docs: Remove a remark that isn't relevant any longer
  docs: Explain how to regenerate import libraries with MSVC tools
  docs: Mention that libraries for MSVC can be built with a cross compiler
  docs: Remove old docs that mention setting up a build environment with lib.exe
  ...

Conflicts:
	doc/ffmpeg.texi
	doc/general.texi
	ffmpeg.c
	libavcodec/Makefile
	libavcodec/dnxhddata.c
	libavformat/mp3enc.c
	libavformat/utils.c
	libavutil/Makefile
	tests/copycooker.sh
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 971c0406 bda168d2
......@@ -556,16 +556,19 @@ The timestamps must be specified in ascending order.
@item -aframes @var{number}
Set the number of audio frames to record.
@item -ar @var{freq}
Set the audio sampling frequency. there is no default for input streams,
for output streams it is set by default to the frequency of the input stream.
Set the audio sampling frequency. For output streams it is set by
default to the frequency of the corresponding input stream. For input
streams this option only makes sense for audio grabbing devices and raw
demuxers and is mapped to the corresponding demuxer options.
@item -ab @var{bitrate}
Set the audio bitrate in bit/s (default = 64k).
@item -aq @var{q}
Set the audio quality (codec-specific, VBR).
@item -ac @var{channels}
Set the number of audio channels. For input streams it is set by
default to 1, for output streams it is set by default to the same
number of audio channels in input.
Set the number of audio channels. For output streams it is set by
default to the number of input audio channels. For input streams
this option only makes sense for audio grabbing devices and raw demuxers
and is mapped to the corresponding demuxer options.
@item -an
Disable audio recording.
@item -acodec @var{codec}
......@@ -733,9 +736,11 @@ Read input at native frame rate. Mainly used to simulate a grab device.
@item -loop_input
Loop over the input stream. Currently it works only for image
streams. This option is used for automatic FFserver testing.
This option is deprecated, use -loop.
@item -loop_output @var{number_of_times}
Repeatedly loop output for formats that support looping such as animated GIF
(0 will loop the output infinitely).
This option is deprecated, use -loop.
@item -threads @var{count}
Thread count.
@item -vsync @var{parameter}
......
......@@ -970,7 +970,8 @@ make install
Your install path (@file{/usr/local/} by default) should now have the
necessary DLL and LIB files under the @file{bin} directory.
@end enumerate
Alternatively, build the libraries with a cross compiler, according to
the instructions below in @ref{Cross compilation for Windows with Linux}.
To use those files with MSVC++, do the same as you would do with
the static libraries, as described above. But in Step 4,
......@@ -983,10 +984,7 @@ libraries (@file{libxxx.a} files) you should add the MSVC import libraries
libraries (@file{libxxx.dll.a} files), as these will give you undefined
reference errors. There should be no need for @file{libmingwex.a},
@file{libgcc.a}, and @file{wsock32.lib}, nor any other external library
statically linked into the DLLs. The @file{bin} directory contains a bunch
of DLL files, but the ones that are actually used to run your application
are the ones with a major version number in their filenames
(i.e. @file{avcodec-51.dll}).
statically linked into the DLLs.
FFmpeg headers do not declare global data for Windows DLLs through the usual
dllexport/dllimport interface. Such data will be exported properly while
......@@ -999,10 +997,41 @@ extern __declspec(dllimport) const AVPixFmtDescriptor av_pix_fmt_descriptors[];
Note that using import libraries created by dlltool requires
the linker optimization option to be set to
"References: Keep Unreferenced Data (/OPT:NOREF)", otherwise
"References: Keep Unreferenced Data (@code{/OPT:NOREF})", otherwise
the resulting binaries will fail during runtime. This isn't
required when using import libraries generated by lib.exe.
This issue is reported upstream at
@url{http://sourceware.org/bugzilla/show_bug.cgi?id=12633}.
To create import libraries that work with the @code{/OPT:REF} option
(which is enabled by default in Release mode), follow these steps:
@enumerate
@item Open @file{Visual Studio 2005 Command Prompt}.
Alternatively, in a normal command line prompt, call @file{vcvars32.bat}
which sets up the environment variables for the Visual C++ tools
(the standard location for this file is
@file{C:\Program Files\Microsoft Visual Studio 8\VC\bin\vcvars32.bat}).
@item Enter the @file{bin} directory where the created LIB and DLL files
are stored.
@item Generate new import libraries with @file{lib.exe}:
@example
lib /machine:i386 /def:..\lib\avcodec-53.def /out:avcodec.lib
lib /machine:i386 /def:..\lib\avdevice-53.def /out:avdevice.lib
lib /machine:i386 /def:..\lib\avfilter-2.def /out:avfilter.lib
lib /machine:i386 /def:..\lib\avformat-53.def /out:avformat.lib
lib /machine:i386 /def:..\lib\avutil-51.def /out:avutil.lib
lib /machine:i386 /def:..\lib\swscale-2.def /out:swscale.lib
@end example
@end enumerate
@anchor{Cross compilation for Windows with Linux}
@subsection Cross compilation for Windows with Linux
You must use the MinGW cross compilation tools available at
......
This diff is collapsed.
......@@ -550,6 +550,7 @@ OBJS-$(CONFIG_MATROSKA_DEMUXER) += mpeg4audio.o mpegaudiodata.o
OBJS-$(CONFIG_MATROSKA_MUXER) += xiph.o mpeg4audio.o \
flacdec.o flacdata.o flac.o \
mpegaudiodata.o vorbis_data.o
OBJS-$(CONFIG_MP3_MUXER) += mpegaudiodata.o mpegaudiodecheader.o
OBJS-$(CONFIG_MOV_DEMUXER) += mpeg4audio.o mpegaudiodata.o
OBJS-$(CONFIG_MOV_MUXER) += mpeg4audio.o mpegaudiodata.o
OBJS-$(CONFIG_MPEGTS_MUXER) += mpegvideo.o mpeg4audio.o
......
This diff is collapsed.
......@@ -49,18 +49,6 @@ typedef struct FlashSVContext {
} FlashSVContext;
static void copy_region(uint8_t *sptr, uint8_t *dptr,
int dx, int dy, int h, int w, int stride)
{
int i;
for (i = dx + h; i > dx; i--) {
memcpy(dptr + i * stride + dy * 3, sptr, w * 3);
sptr += w * 3;
}
}
static av_cold int flashsv_decode_init(AVCodecContext *avctx)
{
FlashSVContext *s = avctx->priv_data;
......@@ -153,14 +141,13 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data,
/* loop over all block columns */
for (j = 0; j < v_blocks + (v_part ? 1 : 0); j++) {
int hp = j * s->block_height; // vertical position in frame
int hs = (j < v_blocks) ? s->block_height : v_part; // block size
int y_pos = j * s->block_height; // vertical position in frame
int cur_blk_height = (j < v_blocks) ? s->block_height : v_part;
/* loop over all block rows */
for (i = 0; i < h_blocks + (h_part ? 1 : 0); i++) {
int wp = i * s->block_width; // horizontal position in frame
int ws = (i < h_blocks) ? s->block_width : h_part; // block size
int x_pos = i * s->block_width; // horizontal position in frame
int cur_blk_width = (i < h_blocks) ? s->block_width : h_part;
/* get the size of the compressed zlib chunk */
int size = get_bits(&gb, 16);
......@@ -173,6 +160,8 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data,
/* skip unchanged blocks, which have size 0 */
if (size) {
/* decompress block */
uint8_t *line = s->tmpblock;
int k;
int ret = inflateReset(&s->zstream);
if (ret != Z_OK) {
av_log(avctx, AV_LOG_ERROR,
......@@ -195,9 +184,15 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data,
"error in decompression of block %dx%d: %d\n", i, j, ret);
/* return -1; */
}
copy_region(s->tmpblock, s->frame.data[0],
s->image_height - (hp + hs + 1),
wp, hs, ws, s->frame.linesize[0]);
/* Flash Screen Video stores the image upside down, so copy
* lines to destination in reverse order. */
for (k = 1; k <= cur_blk_height; k++) {
memcpy(s->frame.data[0] + x_pos * 3 +
(s->image_height - y_pos - k) * s->frame.linesize[0],
line, cur_blk_width * 3);
/* advance source pointer to next line */
line += cur_blk_width * 3;
}
skip_bits_long(&gb, 8 * size); /* skip the consumed bits */
}
}
......
......@@ -208,7 +208,6 @@ static int libschroedinger_decode_frame(AVCodecContext *avccontext,
FfmpegSchroDecoderParams *p_schro_params = avccontext->priv_data;
SchroDecoder *decoder = p_schro_params->decoder;
SchroVideoFormat *format;
AVPicture *picture = data;
SchroBuffer *enc_buf;
SchroFrame* frame;
......@@ -240,7 +239,6 @@ static int libschroedinger_decode_frame(AVCodecContext *avccontext,
go = 1;
} else
outer = 0;
format = p_schro_params->format;
while (go) {
/* Parse data and process result. */
......
......@@ -80,13 +80,6 @@ static int audio_open(AVFormatContext *s1, int is_output, const char *audio_devi
fcntl(audio_fd, F_SETFL, O_NONBLOCK);
s->frame_size = AUDIO_BLOCK_SIZE;
#if 0
tmp = (NB_FRAGMENTS << 16) | FRAGMENT_BITS;
err = ioctl(audio_fd, SNDCTL_DSP_SETFRAGMENT, &tmp);
if (err < 0) {
perror("SNDCTL_DSP_SETFRAGMENT");
}
#endif
/* select format : favour native format */
err = ioctl(audio_fd, SNDCTL_DSP_GETFMTS, &tmp);
......
......@@ -70,7 +70,7 @@ struct x11_grab
XImage *image; /**< X11 image holding the grab */
int use_shm; /**< !0 when using XShm extension */
XShmSegmentInfo shminfo; /**< When using XShm, keeps track of XShm infos */
int nomouse;
int draw_mouse; /**< Set by a private option. */
char *framerate; /**< Set by a private option. */
};
......@@ -104,7 +104,7 @@ x11grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
offset = strchr(dpyname, '+');
if (offset) {
sscanf(offset, "%d,%d", &x_off, &y_off);
x11grab->nomouse= strstr(offset, "nomouse");
x11grab->draw_mouse = !strstr(offset, "nomouse");
*offset= 0;
}
......@@ -218,21 +218,6 @@ x11grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
}
break;
case 32:
#if 0
GetColorInfo (image, &c_info);
if ( c_info.alpha_mask == 0xff000000 && image->green_mask == 0x0000ff00) {
/* byte order is relevant here, not endianness
* endianness is handled by avcodec, but atm no such thing
* as having ABGR, instead of ARGB in a word. Since we
* need this for Solaris/SPARC, but need to do the conversion
* for every frame we do it outside of this loop, cf. below
* this matches both ARGB32 and ABGR32 */
input_pixfmt = PIX_FMT_ARGB32;
} else {
av_log(s1, AV_LOG_ERROR,"image depth %i not supported ... aborting\n", image->bits_per_pixel);
return AVERROR(EIO);
}
#endif
input_pixfmt = PIX_FMT_RGB32;
break;
default:
......@@ -426,7 +411,7 @@ x11grab_read_packet(AVFormatContext *s1, AVPacket *pkt)
}
}
if(!s->nomouse){
if (s->draw_mouse) {
paint_mouse_pointer(image, s);
}
......@@ -467,6 +452,7 @@ x11grab_read_close(AVFormatContext *s1)
static const AVOption options[] = {
{ "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), FF_OPT_TYPE_STRING, {.str = "vga"}, 0, 0, DEC },
{ "framerate", "", OFFSET(framerate), FF_OPT_TYPE_STRING, {.str = "ntsc"}, 0, 0, DEC },
{ "draw_mouse", "Draw the mouse pointer.", OFFSET(draw_mouse), FF_OPT_TYPE_INT, { 1 }, 0, 1, DEC },
{ NULL },
};
......
......@@ -747,12 +747,16 @@ typedef struct AVFormatContext {
int preload;
int max_delay;
#if FF_API_LOOP_OUTPUT
#define AVFMT_NOOUTPUTLOOP -1
#define AVFMT_INFINITEOUTPUTLOOP 0
/**
* number of times to loop output in formats that support it
*
* @deprecated use the 'loop' private option in the gif muxer.
*/
int loop_output;
attribute_deprecated int loop_output;
#endif
int flags;
#define AVFMT_FLAG_GENPTS 0x0001 ///< Generate missing pts even if it requires parsing future frames.
......@@ -770,7 +774,12 @@ typedef struct AVFormatContext {
#define AVFMT_FLAG_PRIV_OPT 0x20000 ///< Enable use of private options by delaying codec open (this could be made default once all code is converted)
#define AVFMT_FLAG_KEEP_SIDE_DATA 0x40000 ///< Dont merge side data but keep it seperate.
int loop_input;
#if FF_API_LOOP_INPUT
/**
* @deprecated, use the 'loop' img2 demuxer private option.
*/
attribute_deprecated int loop_input;
#endif
/**
* decoding: size of data to probe; encoding: unused.
......
......@@ -40,6 +40,8 @@
*/
#include "avformat.h"
#include "libavutil/log.h"
#include "libavutil/opt.h"
/* The GIF format uses reversed order for bitstreams... */
/* at least they don't use PDP_ENDIAN :) */
......@@ -245,8 +247,10 @@ static int gif_image_write_image(AVIOContext *pb,
}
typedef struct {
AVClass *class; /** Class for private options. */
int64_t time, file_time;
uint8_t buffer[100]; /* data chunks */
int loop;
} GIFContext;
static int gif_write_header(AVFormatContext *s)
......@@ -254,7 +258,7 @@ static int gif_write_header(AVFormatContext *s)
GIFContext *gif = s->priv_data;
AVIOContext *pb = s->pb;
AVCodecContext *enc, *video_enc;
int i, width, height, loop_count /*, rate*/;
int i, width, height /*, rate*/;
/* XXX: do we reject audio streams or just ignore them ?
if(s->nb_streams > 1)
......@@ -276,7 +280,6 @@ static int gif_write_header(AVFormatContext *s)
} else {
width = video_enc->width;
height = video_enc->height;
loop_count = s->loop_output;
// rate = video_enc->time_base.den;
}
......@@ -285,7 +288,12 @@ static int gif_write_header(AVFormatContext *s)
return AVERROR(EIO);
}
gif_image_write_header(pb, width, height, loop_count, NULL);
#if FF_API_LOOP_OUTPUT
if (s->loop_output)
gif->loop = s->loop_output;
#endif
gif_image_write_header(pb, width, height, gif->loop, NULL);
avio_flush(s->pb);
return 0;
......@@ -340,6 +348,20 @@ static int gif_write_trailer(AVFormatContext *s)
return 0;
}
#define OFFSET(x) offsetof(GIFContext, x)
#define ENC AV_OPT_FLAG_ENCODING_PARAM
static const AVOption options[] = {
{ "loop", "Number of times to loop the output.", OFFSET(loop), FF_OPT_TYPE_INT, {0}, 0, 65535, ENC },
{ NULL },
};
static const AVClass gif_muxer_class = {
.class_name = "GIF muxer",
.item_name = av_default_item_name,
.version = LIBAVUTIL_VERSION_INT,
.option = options,
};
AVOutputFormat ff_gif_muxer = {
"gif",
NULL_IF_CONFIG_SMALL("GIF Animation"),
......@@ -351,4 +373,5 @@ AVOutputFormat ff_gif_muxer = {
gif_write_header,
gif_write_packet,
gif_write_trailer,
.priv_class = &gif_muxer_class,
};
......@@ -43,6 +43,7 @@ typedef struct {
char *pixel_format; /**< Set by a private option. */
char *video_size; /**< Set by a private option. */
char *framerate; /**< Set by a private option. */
int loop;
} VideoData;
typedef struct {
......@@ -247,6 +248,11 @@ static int read_header(AVFormatContext *s1, AVFormatParameters *ap)
framerate = (AVRational){ap->time_base.den, ap->time_base.num};
#endif
#if FF_API_LOOP_INPUT
if (s1->loop_input)
s->loop = s1->loop_input;
#endif
av_strlcpy(s->path, s1->filename, sizeof(s->path));
s->img_number = 0;
s->img_count = 0;
......@@ -306,7 +312,7 @@ static int read_packet(AVFormatContext *s1, AVPacket *pkt)
if (!s->is_pipe) {
/* loop over input */
if (s1->loop_input && s->img_number > s->img_last) {
if (s->loop && s->img_number > s->img_last) {
s->img_number = s->img_first;
}
if (s->img_number > s->img_last)
......@@ -467,6 +473,7 @@ static const AVOption options[] = {
{ "pixel_format", "", OFFSET(pixel_format), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC },
{ "video_size", "", OFFSET(video_size), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC },
{ "framerate", "", OFFSET(framerate), FF_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC },
{ "loop", "", OFFSET(loop), FF_OPT_TYPE_INT, {.dbl = 0}, 0, 1, DEC },
{ NULL },
};
......
......@@ -939,7 +939,7 @@ static int mkv_write_ass_blocks(AVFormatContext *s, AVIOContext *pb, AVPacket *p
size -= start - data;
sscanf(data, "Dialogue: %d,", &layer);
i = snprintf(buffer, sizeof(buffer), "%"PRId64",%d,",
s->streams[pkt->stream_index]->nb_frames++, layer);
s->streams[pkt->stream_index]->nb_frames, layer);
size = FFMIN(i+size, sizeof(buffer));
memcpy(buffer+i, start, size-i);
......
......@@ -21,10 +21,14 @@
#include <strings.h>
#include "avformat.h"
#include "avio_internal.h"
#include "id3v1.h"
#include "id3v2.h"
#include "rawenc.h"
#include "libavutil/avstring.h"
#include "libavcodec/mpegaudio.h"
#include "libavcodec/mpegaudiodata.h"
#include "libavcodec/mpegaudiodecheader.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/opt.h"
#include "libavcodec/mpegaudio.h"
......@@ -132,15 +136,39 @@ static int id3v2_put_ttag(AVFormatContext *s, const char *str1, const char *str2
return len + ID3v2_HEADER_SIZE;
}
#define VBR_NUM_BAGS 400
#define VBR_TOC_SIZE 100
typedef struct MP3Context {
const AVClass *class;
int id3v2_version;
int64_t frames_offset;
int32_t frames;
int32_t size;
uint32_t want;
uint32_t seen;
uint32_t pos;
uint64_t bag[VBR_NUM_BAGS];
} MP3Context;
static int mp2_write_trailer(struct AVFormatContext *s)
{
uint8_t buf[ID3v1_TAG_SIZE];
MP3Context *mp3 = s->priv_data;
/* write the id3v1 tag */
if (id3v1_create_tag(s, buf) > 0) {
avio_write(s->pb, buf, ID3v1_TAG_SIZE);
avio_flush(s->pb);
}
/* write number of frames */
if (mp3 && mp3->frames_offset) {
avio_seek(s->pb, mp3->frames_offset, SEEK_SET);
avio_wb32(s->pb, s->streams[0]->nb_frames);
avio_seek(s->pb, 0, SEEK_END);
}
avio_flush(s->pb);
return 0;
}
......@@ -160,19 +188,6 @@ AVOutputFormat ff_mp2_muxer = {
#endif
#if CONFIG_MP3_MUXER
#define VBR_NUM_BAGS 400
#define VBR_TOC_SIZE 100
typedef struct MP3Context {
const AVClass *class;
int id3v2_version;
int64_t frames_offset;
int32_t frames;
int32_t size;
uint32_t want;
uint32_t seen;
uint32_t pos;
uint64_t bag[VBR_NUM_BAGS];
} MP3Context;
static const AVOption options[] = {
{ "id3v2_version", "Select ID3v2 version to write. Currently 3 and 4 are supported.",
......
......@@ -3122,8 +3122,9 @@ int av_write_frame(AVFormatContext *s, AVPacket *pkt)
return ret;
ret= s->oformat->write_packet(s, pkt);
if(!ret)
ret= url_ferror(s->pb);
if (ret >= 0)
s->streams[pkt->stream_index]->nb_frames++;
return ret;
}
......@@ -3244,6 +3245,8 @@ int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt){
return ret;
ret= s->oformat->write_packet(s, &opkt);
if (ret >= 0)
s->streams[opkt.stream_index]->nb_frames++;
av_free_packet(&opkt);
pkt= NULL;
......@@ -3268,6 +3271,8 @@ int av_write_trailer(AVFormatContext *s)
break;
ret= s->oformat->write_packet(s, &pkt);
if (ret >= 0)
s->streams[pkt.stream_index]->nb_frames++;
av_free_packet(&pkt);
......
......@@ -80,5 +80,11 @@
#ifndef FF_API_AVSTREAM_QUALITY
#define FF_API_AVSTREAM_QUALITY (LIBAVFORMAT_VERSION_MAJOR < 54)
#endif
#ifndef FF_API_LOOP_INPUT
#define FF_API_LOOP_INPUT (LIBAVFORMAT_VERSION_MAJOR < 54)
#endif
#ifndef FF_API_LOOP_OUTPUT
#define FF_API_LOOP_OUTPUT (LIBAVFORMAT_VERSION_MAJOR < 54)
#endif
#endif /* AVFORMAT_VERSION_H */
......@@ -77,7 +77,8 @@ OBJS-$(ARCH_ARM) += arm/cpu.o
OBJS-$(ARCH_PPC) += ppc/cpu.o
OBJS-$(ARCH_X86) += x86/cpu.o
TESTPROGS = adler32 aes base64 cpu crc des eval lls md5 pca sha tree
TESTPROGS = adler32 aes avstring base64 cpu crc des eval file lfg lls \
md5 opt pca parseutils rational sha tree
TESTPROGS-$(HAVE_LZO1X_999_COMPRESS) += lzo
DIRS = arm bfin sh4 x86
......
......@@ -31,10 +31,42 @@
#ifndef AVUTIL_DICT_H
#define AVUTIL_DICT_H
/**
* @defgroup dict_api Public Dictionary API
* @{
* Dictionaries are used for storing key:value pairs. To create
* an AVDictionary, simply pass an address of a NULL pointer to
* av_dict_set(). NULL can be used as an empty dictionary wherever
* a pointer to an AVDictionary is required.
* Use av_dict_get() to retrieve an entry or iterate over all
* entries and finally av_dict_free() to free the dictionary
* and all its contents.
*
* @code
* AVDictionary *d = NULL; // "create" an empty dictionary
* av_dict_set(&d, "foo", "bar", 0); // add an entry
*
* char *k = av_strdup("key"); // if your strings are already allocated,
* char *v = av_strdup("value"); // you can avoid copying them like this
* av_dict_set(&d, k, v, AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL);
*
* AVDictionaryEntry *t = NULL;
* while (t = av_dict_get(d, "", t, AV_DICT_IGNORE_SUFFIX)) {
* <....> // iterate over all entries in d
* }
*
* av_dict_free(&d);
* @endcode
*
* @}
*/
#define AV_DICT_MATCH_CASE 1
#define AV_DICT_IGNORE_SUFFIX 2
#define AV_DICT_DONT_STRDUP_KEY 4
#define AV_DICT_DONT_STRDUP_VAL 8
#define AV_DICT_DONT_STRDUP_KEY 4 /**< Take ownership of a key that's been
allocated with av_malloc() and children. */
#define AV_DICT_DONT_STRDUP_VAL 8 /**< Take ownership of a value that's been
allocated with av_malloc() and chilren. */
#define AV_DICT_DONT_OVERWRITE 16 ///< Don't overwrite existing entries.
#define AV_DICT_APPEND 32 /**< If the entry already exists, append to it. Note that no
delimiter is added, the strings are simply concatenated. */
......@@ -80,7 +112,8 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags
void av_dict_copy(AVDictionary **dst, AVDictionary *src, int flags);
/**
* Free all the memory allocated for an AVDictionary struct.
* Free all the memory allocated for an AVDictionary struct
* and all keys and values.
*/
void av_dict_free(AVDictionary **m);
......
......@@ -30,76 +30,88 @@
#include "lls.h"
void av_init_lls(LLSModel *m, int indep_count){
void av_init_lls(LLSModel *m, int indep_count)
{
memset(m, 0, sizeof(LLSModel));
m->indep_count= indep_count;
m->indep_count = indep_count;
}
void av_update_lls(LLSModel *m, double *var, double decay){
int i,j;
void av_update_lls(LLSModel *m, double *var, double decay)
{
int i, j;
for(i=0; i<=m->indep_count; i++){
for(j=i; j<=m->indep_count; j++){
for (i = 0; i <= m->indep_count; i++) {
for (j = i; j <= m->indep_count; j++) {
m->covariance[i][j] *= decay;
m->covariance[i][j] += var[i]*var[j];
m->covariance[i][j] += var[i] * var[j];
}
}
}
void av_solve_lls(LLSModel *m, double threshold, int min_order){
int i,j,k;
double (*factor)[MAX_VARS+1]= (void*)&m->covariance[1][0];
double (*covar )[MAX_VARS+1]= (void*)&m->covariance[1][1];
double *covar_y = m->covariance[0];
int count= m->indep_count;
for(i=0; i<count; i++){
for(j=i; j<count; j++){
double sum= covar[i][j];
for(k=i-1; k>=0; k--)
sum -= factor[i][k]*factor[j][k];
if(i==j){
if(sum < threshold)
sum= 1.0;
factor[i][i]= sqrt(sum);
}else
factor[j][i]= sum / factor[i][i];
void av_solve_lls(LLSModel *m, double threshold, int min_order)
{
int i, j, k;
double (*factor)[MAX_VARS + 1] = (void *) &m->covariance[1][0];
double (*covar) [MAX_VARS + 1] = (void *) &m->covariance[1][1];
double *covar_y = m->covariance[0];
int count = m->indep_count;
for (i = 0; i < count; i++) {
for (j = i; j < count; j++) {
double sum = covar[i][j];
for (k = i - 1; k >= 0; k--)
sum -= factor[i][k] * factor[j][k];
if (i == j) {
if (sum < threshold)
sum = 1.0;
factor[i][i] = sqrt(sum);
} else {
factor[j][i] = sum / factor[i][i];
}
}
}
for(i=0; i<count; i++){
double sum= covar_y[i+1];
for(k=i-1; k>=0; k--)
sum -= factor[i][k]*m->coeff[0][k];
m->coeff[0][i]= sum / factor[i][i];
for (i = 0; i < count; i++) {
double sum = covar_y[i + 1];
for (k = i - 1; k >= 0; k--)
sum -= factor[i][k] * m->coeff[0][k];
m->coeff[0][i] = sum / factor[i][i];
}
for(j=count-1; j>=min_order; j--){
for(i=j; i>=0; i--){
double sum= m->coeff[0][i];
for(k=i+1; k<=j; k++)
sum -= factor[k][i]*m->coeff[j][k];
m->coeff[j][i]= sum / factor[i][i];
for (j = count - 1; j >= min_order; j--) {
for (i = j; i >= 0; i--) {
double sum = m->coeff[0][i];
for (k = i + 1; k <= j; k++)
sum -= factor[k][i] * m->coeff[j][k];
m->coeff[j][i] = sum / factor[i][i];
}
m->variance[j]= covar_y[0];
for(i=0; i<=j; i++){
double sum= m->coeff[j][i]*covar[i][i] - 2*covar_y[i+1];
for(k=0; k<i; k++)
sum += 2*m->coeff[j][k]*covar[k][i];
m->variance[j] += m->coeff[j][i]*sum;
m->variance[j] = covar_y[0];
for (i = 0; i <= j; i++) {
double sum = m->coeff[j][i] * covar[i][i] - 2 * covar_y[i + 1];
for (k = 0; k < i; k++)
sum += 2 * m->coeff[j][k] * covar[k][i];
m->variance[j] += m->coeff[j][i] * sum;
}
}
}
double av_evaluate_lls(LLSModel *m, double *param, int order){
double av_evaluate_lls(LLSModel *m, double *param, int order)
{
int i;
double out= 0;
double out = 0;
for(i=0; i<=order; i++)
out+= param[i]*m->coeff[order][i];
for (i = 0; i <= order; i++)
out += param[i] * m->coeff[order][i];
return out;
}
......@@ -109,26 +121,29 @@ double av_evaluate_lls(LLSModel *m, double *param, int order){
#include <stdlib.h>
#include <stdio.h>
int main(void){
int main(void)
{
LLSModel m;
int i, order;
av_init_lls(&m, 3);
for(i=0; i<100; i++){
for (i = 0; i < 100; i++) {
double var[4];
double eval;
var[0] = (rand() / (double)RAND_MAX - 0.5)*2;
var[1] = var[0] + rand() / (double)RAND_MAX - 0.5;
var[2] = var[1] + rand() / (double)RAND_MAX - 0.5;
var[3] = var[2] + rand() / (double)RAND_MAX - 0.5;
var[0] = (rand() / (double) RAND_MAX - 0.5) * 2;
var[1] = var[0] + rand() / (double) RAND_MAX - 0.5;
var[2] = var[1] + rand() / (double) RAND_MAX - 0.5;
var[3] = var[2] + rand() / (double) RAND_MAX - 0.5;
av_update_lls(&m, var, 0.99);
av_solve_lls(&m, 0.001, 0);
for(order=0; order<3; order++){
eval= av_evaluate_lls(&m, var+1, order);
for (order = 0; order < 3; order++) {
eval = av_evaluate_lls(&m, var + 1, order);
printf("real:%9f order:%d pred:%9f var:%f coeffs:%f %9f %9f\n",
var[0], order, eval, sqrt(m.variance[order] / (i+1)),
m.coeff[order][0], m.coeff[order][1], m.coeff[order][2]);
var[0], order, eval, sqrt(m.variance[order] / (i + 1)),
m.coeff[order][0], m.coeff[order][1],
m.coeff[order][2]);
}
}
return 0;
......
......@@ -575,8 +575,9 @@ const AVOption *av_opt_find(void *obj, const char *name, const char *unit,
return o;
while (o = av_next_option(obj, o)) {
if (!strcmp(o->name, name) && (!unit || (o->unit && !strcmp(o->unit, unit))) &&
(o->flags & opt_flags) == opt_flags)
if (!strcmp(o->name, name) && (o->flags & opt_flags) == opt_flags &&
((!unit && o->type != FF_OPT_TYPE_CONST) ||
(unit && o->unit && !strcmp(o->unit, unit))))
return o;
}
return NULL;
......
This diff is collapsed.
98968ceb210ab260a6a7af36767b94d3 *./tests/data/lavf/lavf.gif
2906382 ./tests/data/lavf/lavf.gif
e6089fd4ef3b9df44090ab3650bdd810 *./tests/data/lavf/lavf.gif
2906401 ./tests/data/lavf/lavf.gif
./tests/data/lavf/lavf.gif CRC=0xe5605ff6
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: -1 size:2906382
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: -1 size:2906401
ret:-EINVAL st:-1 flags:0 ts:-1.000000
ret:-EINVAL st:-1 flags:1 ts: 1.894167
ret:-EINVAL st: 0 flags:0 ts: 0.800000
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment