Commit 0ebd8361 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge remote-tracking branch 'qatar/master'

* qatar/master: (27 commits)
  avconv: free packet in write_frame() when discarding due to frame number limit
  FATE: use +/- flag option syntax for vp8 emu-edge tests
  lavf: make av_interleave_packet_per_dts() private.
  lavf: deprecate av_read_packet().
  oggdec: output correct timestamps for Vorbis
  avconv: pass input stream timestamps to audio encoders
  lavc: shrink encoded audio packet size after encoding.
  xa: set correct bit rate
  xa: do not set bit_rate, block_align, or bits_per_coded_sample
  xa: fix end-of-file handling
  xa: fix timestamp calculation
  bink: fix typo in FFALIGN() argument
  bink: align plane width to 8 when calculating bundle sizes
  doc: pass -Idoc texi2html and texi2pod
  doc: texi2pod: add -I flag
  movenc: Add a min_frag_duration option
  rtsp: Set the default delay to 0.1 s for the RTSP/SDP/RTP demuxers
  libavformat: Set the default for the max_delay option to -1
  Generate manpages for AV{Format,Codec}Context AVOptions.
  doc/avconv: remove entries for AVOptions.
  ...

Conflicts:
	doc/Makefile
	doc/ffmpeg.texi
	doc/muxers.texi
	ffmpeg.c
	libavcodec/Makefile
	libavcodec/options.c
	libavcodec/vp8.c
	libavformat/options.c
	tests/fate/demux.mak
	tests/ref/fate/truemotion1-15
	tests/ref/fate/truemotion1-24
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 745a33a4 c9594fe0
......@@ -19,7 +19,7 @@ PROGS := $(PROGS-yes:%=%$(EXESUF))
INSTPROGS = $(PROGS-yes:%=%$(PROGSSUF)$(EXESUF))
OBJS = $(PROGS-yes:%=%.o) cmdutils.o
TESTTOOLS = audiogen videogen rotozoom tiny_psnr base64
HOSTPROGS := $(TESTTOOLS:%=tests/%)
HOSTPROGS := $(TESTTOOLS:%=tests/%) doc/print_options
TOOLS = qt-faststart trasher
TOOLS-$(CONFIG_ZLIB) += cws2fws
......
......@@ -28,18 +28,27 @@ doc/%.txt: doc/%.texi
$(Q)$(TEXIDEP)
$(M)makeinfo --force --no-headers -o $@ $< 2>/dev/null
doc/print_options.o: libavformat/options_table.h libavcodec/options_table.h
GENTEXI = format codec
GENTEXI := $(GENTEXI:%=doc/avoptions_%.texi)
$(GENTEXI): TAG = GENTEXI
$(GENTEXI): doc/avoptions_%.texi: doc/print_options
$(M)doc/print_options $* > $@
doc/%.html: TAG = HTML
doc/%.html: doc/%.texi $(SRC_PATH)/doc/t2h.init
doc/%.html: doc/%.texi $(SRC_PATH)/doc/t2h.init $(GENTEXI)
$(Q)$(TEXIDEP)
$(M)texi2html -monolithic --init-file $(SRC_PATH)/doc/t2h.init --output $@ $<
$(M)texi2html -I doc -monolithic --init-file $(SRC_PATH)/doc/t2h.init --output $@ $<
doc/%.pod: TAG = POD
doc/%.pod: doc/%.texi
doc/%.pod: doc/%.texi $(GENTEXI)
$(Q)$(TEXIDEP)
$(M)$(SRC_PATH)/doc/texi2pod.pl $< $@
$(M)$(SRC_PATH)/doc/texi2pod.pl -Idoc $< $@
doc/%.1: TAG = MAN
doc/%.1: doc/%.pod
doc/%.1: doc/%.pod $(GENTEXI)
$(M)pod2man --section=1 --center=" " --release=" " $< > $@
$(DOCS): | doc
......@@ -57,7 +66,7 @@ uninstall-man:
$(RM) $(addprefix "$(MANDIR)/man1/",$(ALLMANPAGES))
clean::
$(RM) $(TXTPAGES) doc/*.html doc/*.pod doc/*.1 $(CLEANSUFFIXES:%=doc/%)
$(RM) $(TXTPAGES) doc/*.html doc/*.pod doc/*.1 $(CLEANSUFFIXES:%=doc/%) doc/avoptions_*.texi
-include $(wildcard $(DOCS:%=%.d))
......
......@@ -175,3 +175,6 @@ use @option{-option 0}/@option{-option 1}.
Note2 old undocumented way of specifying per-stream AVOptions by prepending
v/a/s to the options name is now obsolete and will be removed soon.
@include avoptions_codec.texi
@include avoptions_format.texi
......@@ -370,25 +370,7 @@ pad=width:height:x:y:color instead.
@item -vn (@emph{output})
Disable video recording.
@item -bt @var{tolerance}
Set video bitrate tolerance (in bits, default 4000k).
Has a minimum value of: (target_bitrate/target_framerate).
In 1-pass mode, bitrate tolerance specifies how far ratecontrol is
willing to deviate from the target average bitrate value. This is
not related to min/max bitrate. Lowering tolerance too much has
an adverse effect on quality.
@item -maxrate @var{bitrate}
Set max video bitrate (in bit/s).
Requires -bufsize to be set.
@item -minrate @var{bitrate}
Set min video bitrate (in bit/s).
Most useful in setting up a CBR encode:
@example
ffmpeg -i myfile.avi -b:v 4000k -minrate 4000k -maxrate 4000k -bufsize 1835k out.m2v
@end example
It is of little use elsewise.
@item -bufsize @var{size}
Set video buffer verifier buffer size (in bits).
@item -vcodec @var{codec} (@emph{output})
Set the video codec. This is an alias for @code{-codec:v}.
@item -same_quant
......@@ -435,197 +417,14 @@ Set pixel format. Use @code{-pix_fmts} to show all the supported
pixel formats.
@item -sws_flags @var{flags} (@emph{input/output})
Set SwScaler flags.
@item -g @var{gop_size}
Set the group of pictures size.
@item -intra
deprecated, use -g 1
@item -vdt @var{n}
Discard threshold.
@item -qmin @var{q}
minimum video quantizer scale (VBR)
@item -qmax @var{q}
maximum video quantizer scale (VBR)
@item -qdiff @var{q}
maximum difference between the quantizer scales (VBR)
@item -qblur @var{blur}
video quantizer scale blur (VBR) (range 0.0 - 1.0)
@item -qcomp @var{compression}
video quantizer scale compression (VBR) (default 0.5).
Constant of ratecontrol equation. Recommended range for default rc_eq: 0.0-1.0
@item -lmin @var{lambda}
minimum video lagrange factor (VBR)
@item -lmax @var{lambda}
max video lagrange factor (VBR)
@item -mblmin @var{lambda}
minimum macroblock quantizer scale (VBR)
@item -mblmax @var{lambda}
maximum macroblock quantizer scale (VBR)
These four options (lmin, lmax, mblmin, mblmax) use 'lambda' units,
but you may use the QP2LAMBDA constant to easily convert from 'q' units:
@example
ffmpeg -i src.ext -lmax 21*QP2LAMBDA dst.ext
@end example
@item -rc_init_cplx @var{complexity}
initial complexity for single pass encoding
@item -b_qfactor @var{factor}
qp factor between P- and B-frames
@item -i_qfactor @var{factor}
qp factor between P- and I-frames
@item -b_qoffset @var{offset}
qp offset between P- and B-frames
@item -i_qoffset @var{offset}
qp offset between P- and I-frames
@item -rc_eq @var{equation}
Set rate control equation (see section "Expression Evaluation")
(default = @code{tex^qComp}).
When computing the rate control equation expression, besides the
standard functions defined in the section "Expression Evaluation", the
following functions are available:
@table @var
@item bits2qp(bits)
@item qp2bits(qp)
@end table
and the following constants are available:
@table @var
@item iTex
@item pTex
@item tex
@item mv
@item fCode
@item iCount
@item mcVar
@item var
@item isI
@item isP
@item isB
@item avgQP
@item qComp
@item avgIITex
@item avgPITex
@item avgPPTex
@item avgBPTex
@item avgTex
@end table
@item -rc_override[:@var{stream_specifier}] @var{override} (@emph{output,per-stream})
Rate control override for specific intervals, formatted as "int,int,int"
list separated with slashes. Two first values are the beginning and
end frame numbers, last one is quantizer to use if positive, or quality
factor if negative.
@item -me_method @var{method}
Set motion estimation method to @var{method}.
Available methods are (from lowest to best quality):
@table @samp
@item zero
Try just the (0, 0) vector.
@item phods
@item log
@item x1
@item hex
@item umh
@item epzs
(default method)
@item full
exhaustive search (slow and marginally better than epzs)
@end table
@item -dct_algo @var{algo}
Set DCT algorithm to @var{algo}. Available values are:
@table @samp
@item 0
FF_DCT_AUTO (default)
@item 1
FF_DCT_FASTINT
@item 2
FF_DCT_INT
@item 3
FF_DCT_MMX
@item 4
FF_DCT_MLIB
@item 5
FF_DCT_ALTIVEC
@end table
@item -idct_algo @var{algo}
Set IDCT algorithm to @var{algo}. Available values are:
@table @samp
@item 0
FF_IDCT_AUTO (default)
@item 1
FF_IDCT_INT
@item 2
FF_IDCT_SIMPLE
@item 3
FF_IDCT_SIMPLEMMX
@item 4
FF_IDCT_LIBMPEG2MMX
@item 5
FF_IDCT_PS2
@item 6
FF_IDCT_MLIB
@item 7
FF_IDCT_ARM
@item 8
FF_IDCT_ALTIVEC
@item 9
FF_IDCT_SH4
@item 10
FF_IDCT_SIMPLEARM
@end table
@item -er @var{n}
Set error resilience to @var{n}.
@table @samp
@item 1
FF_ER_CAREFUL (default)
@item 2
FF_ER_COMPLIANT
@item 3
FF_ER_AGGRESSIVE
@item 4
FF_ER_VERY_AGGRESSIVE
@end table
@item -ec @var{bit_mask}
Set error concealment to @var{bit_mask}. @var{bit_mask} is a bit mask of
the following values:
@table @samp
@item 1
FF_EC_GUESS_MVS (default = enabled)
@item 2
FF_EC_DEBLOCK (default = enabled)
@end table
@item -bf @var{frames}
Use 'frames' B-frames (supported for MPEG-1, MPEG-2 and MPEG-4).
@item -mbd @var{mode}
macroblock decision
@table @samp
@item 0
FF_MB_DECISION_SIMPLE: Use mb_cmp (cannot change it yet in ffmpeg).
@item 1
FF_MB_DECISION_BITS: Choose the one which needs the fewest bits.
@item 2
FF_MB_DECISION_RD: rate distortion
@end table
@item -4mv
Use four motion vector by macroblock (MPEG-4 only).
@item -part
Use data partitioning (MPEG-4 only).
@item -bug @var{param}
Work around encoder bugs that are not auto-detected.
@item -strict @var{strictness}
How strictly to follow the standards.
@item -aic
Enable Advanced intra coding (h263+).
@item -umv
Enable Unlimited Motion Vector (h263+)
@item -deinterlace
Deinterlace pictures.
......@@ -696,28 +495,6 @@ of supported sample formats.
@table @option
@item -atag @var{fourcc/tag} (@emph{output})
Force audio tag/fourcc. This is an alias for @code{-tag:a}.
@item -audio_service_type @var{type}
Set the type of service that the audio stream contains.
@table @option
@item ma
Main Audio Service (default)
@item ef
Effects
@item vi
Visually Impaired
@item hi
Hearing Impaired
@item di
Dialogue
@item co
Commentary
@item em
Emergency
@item vo
Voice Over
@item ka
Karaoke
@end table
@item -absf @var{bitstream_filter}
Deprecated, see -bsf
@end table
......@@ -945,8 +722,6 @@ Exit after ffmpeg has been running for @var{duration} seconds.
Dump each input packet to stderr.
@item -hex (@emph{global})
When dumping packets, also dump the payload.
@item -ps @var{size}
Set RTP payload size in bytes.
@item -re (@emph{input})
Read input at native frame rate. Mainly used to simulate a grab device.
@item -loop_input
......@@ -957,8 +732,6 @@ This option is deprecated, use -loop 1.
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}
Video sync method.
For compatibility reasons old values can be specified as numbers.
......@@ -1294,6 +1067,19 @@ ffmpeg -i test1.avi -i test2.avi -map 0.3 -map 0.2 -map 0.1 -map 0.0 -c copy tes
The resulting output file @file{test12.avi} will contain first four streams from
the input file in reverse order.
@item
To force CBR video output:
@example
ffmpeg -i myfile.avi -b 4000k -minrate 4000k -maxrate 4000k -bufsize 1835k out.m2v
@end example
@item
The four options lmin, lmax, mblmin and mblmax use 'lambda' units,
but you may use the QP2LAMBDA constant to easily convert from 'q' units:
@example
ffmpeg -i src.ext -lmax 21*QP2LAMBDA dst.ext
@end example
@end itemize
@c man end EXAMPLES
......
......@@ -181,8 +181,15 @@ Allow the caller to manually choose when to cut fragments, by
calling @code{av_write_frame(ctx, NULL)} to write a fragment with
the packets written so far. (This is only useful with other
applications integrating libavformat, not from @command{ffmpeg}.)
@item -min_frag_duration @var{duration}
Don't create fragments that are shorter than @var{duration} microseconds long.
@end table
If more than one condition is specified, fragments are cut when
one of the specified conditions is fulfilled. The exception to this is
@code{-min_frag_duration}, which has to be fulfilled for any of the other
conditions to apply.
Additionally, the way the output file is written can be adjusted
through a few other options:
......
/*
* Copyright (c) 2012 Anton Khirnov
*
* This file is part of Libav.
*
* Libav 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.
*
* Libav 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 Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* generate texinfo manpages for avoptions
*/
#include <stddef.h>
#include <string.h>
#include <float.h>
#include "libavformat/avformat.h"
#include "libavcodec/avcodec.h"
#include "libavutil/opt.h"
static void print_usage(void)
{
fprintf(stderr, "Usage: enum_options type\n"
"type: format codec\n");
exit(1);
}
static void print_option(const AVOption *opts, const AVOption *o, int per_stream)
{
printf("@item -%s%s @var{", o->name, per_stream ? "[:stream_specifier]" : "");
switch (o->type) {
case AV_OPT_TYPE_BINARY: printf("hexadecimal string"); break;
case AV_OPT_TYPE_STRING: printf("string"); break;
case AV_OPT_TYPE_INT:
case AV_OPT_TYPE_INT64: printf("integer"); break;
case AV_OPT_TYPE_FLOAT:
case AV_OPT_TYPE_DOUBLE: printf("float"); break;
case AV_OPT_TYPE_RATIONAL: printf("rational number"); break;
case AV_OPT_TYPE_FLAGS: printf("flags"); break;
default: printf("value"); break;
}
printf("} (@emph{");
if (o->flags & AV_OPT_FLAG_DECODING_PARAM) {
printf("input");
if (o->flags & AV_OPT_FLAG_ENCODING_PARAM)
printf("/");
}
if (o->flags & AV_OPT_FLAG_ENCODING_PARAM) printf("output");
if (o->flags & AV_OPT_FLAG_AUDIO_PARAM) printf(",audio");
if (o->flags & AV_OPT_FLAG_VIDEO_PARAM) printf(",video");
if (o->flags & AV_OPT_FLAG_SUBTITLE_PARAM) printf(",subtitles");
printf("})\n");
if (o->help)
printf("%s\n", o->help);
if (o->unit) {
const AVOption *u;
printf("\nPossible values:\n@table @samp\n");
for (u = opts; u->name; u++) {
if (u->type == AV_OPT_TYPE_CONST && u->unit && !strcmp(u->unit, o->unit))
printf("@item %s\n%s\n", u->name, u->help ? u->help : "");
}
printf("@end table\n");
}
}
static void show_opts(const AVOption *opts, int per_stream)
{
const AVOption *o;
printf("@table @option\n");
for (o = opts; o->name; o++) {
if (o->type != AV_OPT_TYPE_CONST)
print_option(opts, o, per_stream);
}
printf("@end table\n");
}
static void show_format_opts(void)
{
#include "libavformat/options_table.h"
printf("@section Format AVOptions\n");
show_opts(options, 0);
}
static void show_codec_opts(void)
{
#include "libavcodec/options_table.h"
printf("@section Codec AVOptions\n");
show_opts(options, 1);
}
int main(int argc, char **argv)
{
if (argc < 2)
print_usage();
if (!strcmp(argv[1], "format"))
show_format_opts();
else if (!strcmp(argv[1], "codec"))
show_codec_opts();
else
print_usage();
return 0;
}
......@@ -318,9 +318,9 @@ Accept packets only from negotiated peer address and port.
@end table
When receiving data over UDP, the demuxer tries to reorder received packets
(since they may arrive out of order, or packets may get lost totally). In
order for this to be enabled, a maximum delay must be specified in the
@code{max_delay} field of AVFormatContext.
(since they may arrive out of order, or packets may get lost totally). This
can be disabled by setting the maximum demuxing delay to zero (via
the @code{max_delay} field of AVFormatContext).
When watching multi-bitrate Real-RTSP streams with @command{ffplay}, the
streams to display can be chosen with @code{-vst} @var{n} and
......
......@@ -36,7 +36,7 @@ $shift = "";
%defs = ();
$fnno = 1;
$inf = "";
$ibase = "";
@ibase = ();
while ($_ = shift) {
if (/^-D(.*)$/) {
......@@ -52,6 +52,8 @@ while ($_ = shift) {
die "flags may only contain letters, digits, hyphens, dashes and underscores\n"
unless $flag =~ /^[a-zA-Z0-9_-]+$/;
$defs{$flag} = $value;
} elsif (/^-I(.*)$/) {
push @ibase, $1 ne "" ? $1 : shift;
} elsif (/^-/) {
usage();
} else {
......@@ -61,10 +63,12 @@ while ($_ = shift) {
}
}
push @ibase, ".";
if (defined $in) {
$inf = gensym();
open($inf, "<$in") or die "opening \"$in\": $!\n";
$ibase = $1 if $in =~ m|^(.+)/[^/]+$|;
push @ibase, $1 if $in =~ m|^(.+)/[^/]+$|;
} else {
$inf = \*STDIN;
}
......@@ -74,7 +78,7 @@ if (defined $out) {
}
while(defined $inf) {
while(<$inf>) {
INF: while(<$inf>) {
# Certain commands are discarded without further processing.
/^\@(?:
[a-z]+index # @*index: useful only in complete manual
......@@ -104,11 +108,10 @@ while(<$inf>) {
push @instack, $inf;
$inf = gensym();
# Try cwd and $ibase.
open($inf, "<" . $1)
or open($inf, "<" . $ibase . "/" . $1)
or die "cannot open $1 or $ibase/$1: $!\n";
next;
for (@ibase) {
open($inf, "<" . $_ . "/" . $1) and next INF;
}
die "cannot open $1: $!\n";
};
# Look for blocks surrounded by @c man begin SECTION ... @c man end.
......
......@@ -1007,8 +1007,10 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
* reordering, see do_video_out()
*/
if (!(avctx->codec_type == AVMEDIA_TYPE_VIDEO && avctx->codec)) {
if (ost->frame_number >= ost->max_frames)
if (ost->frame_number >= ost->max_frames) {
av_free_packet(pkt);
return;
}
ost->frame_number++;
}
......@@ -1083,6 +1085,7 @@ static int encode_audio_frame(AVFormatContext *s, OutputStream *ost,
exit_program(1);
}
frame->pts = ost->sync_opts;
ost->sync_opts += frame->nb_samples;
}
......@@ -5065,7 +5068,7 @@ static const OptionDef options[] = {
{ "padleft", HAS_ARG | OPT_VIDEO, {(void*)opt_pad}, "Removed, use the pad filter instead", "size" },
{ "padright", HAS_ARG | OPT_VIDEO, {(void*)opt_pad}, "Removed, use the pad filter instead", "size" },
{ "padcolor", HAS_ARG | OPT_VIDEO, {(void*)opt_pad}, "Removed, use the pad filter instead", "color" },
{ "intra", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, {(void*)&intra_only}, "use only intra frames"},
{ "intra", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, {(void*)&intra_only}, "deprecated use -g 1"},
{ "vn", OPT_BOOL | OPT_VIDEO | OPT_OFFSET, {.off = OFFSET(video_disable)}, "disable video" },
{ "vdt", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)&video_discard}, "discard threshold", "n" },
{ "rc_override", HAS_ARG | OPT_EXPERT | OPT_VIDEO | OPT_STRING | OPT_SPEC, {.off = OFFSET(rc_overrides)}, "rate control override for specific intervals", "override" },
......
......@@ -616,7 +616,7 @@ OBJS-$(CONFIG_MPEGTS_DEMUXER) += mpeg4audio.o mpegaudiodata.o
OBJS-$(CONFIG_MXF_MUXER) += timecode.o
OBJS-$(CONFIG_NUT_MUXER) += mpegaudiodata.o
OBJS-$(CONFIG_OGG_DEMUXER) += flacdec.o flacdata.o flac.o \
dirac.o mpeg12data.o vorbis_data.o
dirac.o mpeg12data.o vorbis_parser.o vorbis_data.o
OBJS-$(CONFIG_OGG_MUXER) += xiph.o flacdec.o flacdata.o flac.o \
vorbis_data.o
OBJS-$(CONFIG_RTP_MUXER) += mpeg4audio.o mpegvideo.o xiph.o
......
......@@ -146,6 +146,8 @@ enum BlockTypes {
*/
static void init_lengths(BinkContext *c, int width, int bw)
{
width = FFALIGN(width, 8);
c->bundle[BINK_SRC_BLOCK_TYPES].len = av_log2((width >> 3) + 511) + 1;
c->bundle[BINK_SRC_SUB_BLOCK_TYPES].len = av_log2(((width + 7) >> 4) + 511) + 1;
......
This diff is collapsed.
This diff is collapsed.
......@@ -1069,8 +1069,15 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
if (fs_tmp)
avctx->frame_size = fs_tmp;
}
if (!ret)
if (!ret) {
if (!user_packet && avpkt->data) {
uint8_t *new_data = av_realloc(avpkt->data, avpkt->size);
if (new_data)
avpkt->data = new_data;
}
avctx->frame_number++;
}
if (ret < 0 || !*got_packet_ptr)
av_free_packet(avpkt);
......
......@@ -642,7 +642,7 @@ void decode_mb_mode(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y, uint8_
if (s->segmentation.update_map) {
int bit = vp56_rac_get_prob(c, s->prob->segmentid[0]);
*segment = vp56_rac_get_prob(c, s->prob->segmentid[1+bit]) + 2*bit;
} else
} else if (s->segmentation.enabled)
*segment = ref ? *ref : *segment;
s->segment = *segment;
......
......@@ -1332,7 +1332,11 @@ int av_find_best_stream(AVFormatContext *ic,
AVCodec **decoder_ret,
int flags);
#if FF_API_READ_PACKET
/**
* @deprecated use AVFMT_FLAG_NOFILLIN | AVFMT_FLAG_NOPARSE to read raw
* unprocessed packets
*
* Read a transport packet from a media file.
*
* This function is obsolete and should never be used.
......@@ -1342,7 +1346,9 @@ int av_find_best_stream(AVFormatContext *ic,
* @param pkt is filled
* @return 0 if OK, AVERROR_xxx on error
*/
attribute_deprecated
int av_read_packet(AVFormatContext *s, AVPacket *pkt);
#endif
/**
* Return the next frame of a stream.
......@@ -1539,23 +1545,15 @@ int av_write_frame(AVFormatContext *s, AVPacket *pkt);
*/
int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt);
#if FF_API_INTERLEAVE_PACKET
/**
* Interleave a packet per dts in an output media file.
*
* Packets with pkt->destruct == av_destruct_packet will be freed inside this
* function, so they cannot be used after it. Note that calling av_free_packet()
* on them is still safe.
*
* @param s media file handle
* @param out the interleaved packet will be output here
* @param pkt the input packet
* @param flush 1 if no further packets are available as input and all
* remaining packets should be output
* @return 1 if a packet was output, 0 if no packet could be output,
* < 0 if an error occurred
* @deprecated this function was never meant to be called by the user
* programs.
*/
attribute_deprecated
int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out,
AVPacket *pkt, int flush);
#endif
/**
* Write the stream trailer to an output media file and free the
......
......@@ -838,7 +838,7 @@ static int read_gab2_sub(AVStream *st, AVPacket *pkt) {
ast->sub_ctx->pb = pb;
if (!avformat_open_input(&ast->sub_ctx, "", sub_demuxer, NULL)) {
av_read_packet(ast->sub_ctx, &ast->sub_pkt);
ff_read_packet(ast->sub_ctx, &ast->sub_pkt);
*st->codec = *ast->sub_ctx->streams[0]->codec;
ast->sub_ctx->streams[0]->codec->extradata = NULL;
time_base = ast->sub_ctx->streams[0]->time_base;
......@@ -880,7 +880,7 @@ static AVStream *get_subtitle_pkt(AVFormatContext *s, AVStream *next_st,
ast = sub_st->priv_data;
*pkt = ast->sub_pkt;
pkt->stream_index = sub_st->index;
if (av_read_packet(ast->sub_ctx, &ast->sub_pkt) < 0)
if (ff_read_packet(ast->sub_ctx, &ast->sub_pkt) < 0)
ast->sub_pkt.data = NULL;
}
return sub_st;
......@@ -1364,7 +1364,7 @@ static void seek_subtitle(AVStream *st, AVStream *st2, int64_t timestamp)
av_free_packet(&ast2->sub_pkt);
if (avformat_seek_file(ast2->sub_ctx, 0, INT64_MIN, ts2, ts2, 0) >= 0 ||
avformat_seek_file(ast2->sub_ctx, 0, ts2, ts2, INT64_MAX, 0) >= 0)
av_read_packet(ast2->sub_ctx, &ast2->sub_pkt);
ff_read_packet(ast2->sub_ctx, &ast2->sub_pkt);
}
static int avi_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
......
......@@ -991,7 +991,7 @@ static int gxf_interleave_packet(AVFormatContext *s, AVPacket *out, AVPacket *pk
if (pkt && s->streams[pkt->stream_index]->codec->codec_type == AVMEDIA_TYPE_VIDEO)
pkt->duration = 2; // enforce 2 fields
return ff_audio_rechunk_interleave(s, out, pkt, flush,
av_interleave_packet_per_dts, gxf_compare_field_nb);
ff_interleave_packet_per_dts, gxf_compare_field_nb);
}
static const AVOption options[] = {
......
......@@ -803,6 +803,7 @@ int ff_id3v2_parse_apic(AVFormatContext *s, ID3v2ExtraMeta **extra_meta)
st->attached_pic.size = apic->len;
st->attached_pic.destruct = av_destruct_packet;
st->attached_pic.stream_index = st->index;
st->attached_pic.flags |= AV_PKT_FLAG_KEY;
apic->data = NULL;
apic->len = 0;
......
......@@ -317,4 +317,31 @@ int ff_add_param_change(AVPacket *pkt, int32_t channels,
*/
int ff_framehash_write_header(AVFormatContext *s);
/**
* Read a transport packet from a media file.
*
* @param s media file handle
* @param pkt is filled
* @return 0 if OK, AVERROR_xxx on error
*/
int ff_read_packet(AVFormatContext *s, AVPacket *pkt);
/**
* Interleave a packet per dts in an output media file.
*
* Packets with pkt->destruct == av_destruct_packet will be freed inside this
* function, so they cannot be used after it. Note that calling av_free_packet()
* on them is still safe.
*
* @param s media file handle
* @param out the interleaved packet will be output here
* @param pkt the input packet
* @param flush 1 if no further packets are available as input and all
* remaining packets should be output
* @return 1 if a packet was output, 0 if no packet could be output,
* < 0 if an error occurred
*/
int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out,
AVPacket *pkt, int flush);
#endif /* AVFORMAT_INTERNAL_H */
......@@ -57,6 +57,7 @@ static const AVOption options[] = {
{ "iods_audio_profile", "iods audio profile atom.", offsetof(MOVMuxContext, iods_audio_profile), AV_OPT_TYPE_INT, {.dbl = -1}, -1, 255, AV_OPT_FLAG_ENCODING_PARAM},
{ "iods_video_profile", "iods video profile atom.", offsetof(MOVMuxContext, iods_video_profile), AV_OPT_TYPE_INT, {.dbl = -1}, -1, 255, AV_OPT_FLAG_ENCODING_PARAM},
{ "frag_duration", "Maximum fragment duration", offsetof(MOVMuxContext, max_fragment_duration), AV_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM},
{ "min_frag_duration", "Minimum fragment duration", offsetof(MOVMuxContext, min_fragment_duration), AV_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM},
{ "frag_size", "Maximum fragment size", offsetof(MOVMuxContext, max_fragment_size), AV_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM},
{ "ism_lookahead", "Number of lookahead entries for ISM files", offsetof(MOVMuxContext, ism_lookahead), AV_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM},
{ NULL },
......@@ -2893,21 +2894,25 @@ static int mov_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
unsigned int samples_in_chunk = 0;
int size= pkt->size;
uint8_t *reformatted_data = NULL;
int64_t frag_duration = 0;
if (!s->pb->seekable && !(mov->flags & FF_MOV_FLAG_EMPTY_MOOV))
return 0; /* Can't handle that */
if (!size) return 0; /* Discard 0 sized packets */
if ((mov->max_fragment_duration && trk->entry &&
av_rescale_q(pkt->dts - trk->cluster[0].dts,
s->streams[pkt->stream_index]->time_base,
AV_TIME_BASE_Q) >= mov->max_fragment_duration) ||
if (trk->entry)
frag_duration = av_rescale_q(pkt->dts - trk->cluster[0].dts,
s->streams[pkt->stream_index]->time_base,
AV_TIME_BASE_Q);
if ((mov->max_fragment_duration &&
frag_duration >= mov->max_fragment_duration) ||
(mov->max_fragment_size && mov->mdat_size + size >= mov->max_fragment_size) ||
(mov->flags & FF_MOV_FLAG_FRAG_KEYFRAME &&
enc->codec_type == AVMEDIA_TYPE_VIDEO &&
trk->entry && pkt->flags & AV_PKT_FLAG_KEY)) {
mov_flush_fragment(s);
if (frag_duration >= mov->min_fragment_duration)
mov_flush_fragment(s);
}
if (mov->flags & FF_MOV_FLAG_FRAGMENT) {
......
......@@ -154,6 +154,7 @@ typedef struct MOVMuxContext {
int fragments;
int max_fragment_duration;
int min_fragment_duration;
int max_fragment_size;
int ism_lookahead;
AVIOContext *mdat_buf;
......
......@@ -318,6 +318,8 @@ static int mpeg_mux_init(AVFormatContext *ctx)
s->packet_size = ctx->packet_size;
} else
s->packet_size = 2048;
if (ctx->max_delay < 0) /* Not set by the caller */
ctx->max_delay = 0;
s->vcd_padding_bytes_written = 0;
s->vcd_padding_bitrate=0;
......
......@@ -491,6 +491,9 @@ static int mpegts_write_header(AVFormatContext *s)
const char *provider_name;
int *pids;
if (s->max_delay < 0) /* Not set by the caller */
s->max_delay = 0;
// round up to a whole number of TS packets
ts->pes_payload_size = (ts->pes_payload_size + 14 + 183) / 184 * 184 - 14;
......
......@@ -28,6 +28,7 @@
#include "libavutil/dict.h"
#include "libavcodec/get_bits.h"
#include "libavcodec/bytestream.h"
#include "libavcodec/vorbis_parser.h"
#include "avformat.h"
#include "internal.h"
#include "oggdec.h"
......@@ -162,6 +163,9 @@ ff_vorbis_comment(AVFormatContext * as, AVDictionary **m, const uint8_t *buf, in
struct oggvorbis_private {
unsigned int len[3];
unsigned char *packet[3];
VorbisParseContext vp;
int64_t final_pts;
int final_duration;
};
......@@ -251,7 +255,6 @@ vorbis_header (AVFormatContext * s, int idx)
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = CODEC_ID_VORBIS;
st->need_parsing = AVSTREAM_PARSE_HEADERS;
if (srate > 0) {
st->codec->sample_rate = srate;
......@@ -269,15 +272,91 @@ vorbis_header (AVFormatContext * s, int idx)
}
}
} else {
int ret;
st->codec->extradata_size =
fixup_vorbis_headers(s, priv, &st->codec->extradata);
if ((ret = avpriv_vorbis_parse_extradata(st->codec, &priv->vp))) {
av_freep(&st->codec->extradata);
st->codec->extradata_size = 0;
return ret;
}
}
return 1;
}
static int vorbis_packet(AVFormatContext *s, int idx)
{
struct ogg *ogg = s->priv_data;
struct ogg_stream *os = ogg->streams + idx;
struct oggvorbis_private *priv = os->private;
int duration;
/* first packet handling
here we parse the duration of each packet in the first page and compare
the total duration to the page granule to find the encoder delay and
set the first timestamp */
if (!os->lastpts) {
int seg;
uint8_t *last_pkt = os->buf + os->pstart;
uint8_t *next_pkt = last_pkt;
int first_duration = 0;
avpriv_vorbis_parse_reset(&priv->vp);
duration = 0;
for (seg = 0; seg < os->nsegs; seg++) {
if (os->segments[seg] < 255) {
int d = avpriv_vorbis_parse_frame(&priv->vp, last_pkt, 1);
if (d < 0) {
duration = os->granule;
break;
}
if (!duration)
first_duration = d;
duration += d;
last_pkt = next_pkt + os->segments[seg];
}
next_pkt += os->segments[seg];
}
os->lastpts = os->lastdts = os->granule - duration;
s->streams[idx]->start_time = os->lastpts + first_duration;
if (s->streams[idx]->duration)
s->streams[idx]->duration -= s->streams[idx]->start_time;
s->streams[idx]->cur_dts = AV_NOPTS_VALUE;
priv->final_pts = AV_NOPTS_VALUE;
avpriv_vorbis_parse_reset(&priv->vp);
}
/* parse packet duration */
if (os->psize > 0) {
duration = avpriv_vorbis_parse_frame(&priv->vp, os->buf + os->pstart, 1);
if (duration <= 0) {
os->pflags |= AV_PKT_FLAG_CORRUPT;
return 0;
}
os->pduration = duration;
}
/* final packet handling
here we save the pts of the first packet in the final page, sum up all
packet durations in the final page except for the last one, and compare
to the page granule to find the duration of the final packet */
if (os->flags & OGG_FLAG_EOS) {
if (os->lastpts != AV_NOPTS_VALUE) {
priv->final_pts = os->lastpts;
priv->final_duration = 0;
}
if (os->segp == os->nsegs)
os->pduration = os->granule - priv->final_pts - priv->final_duration;
priv->final_duration += os->pduration;
}
return 0;
}
const struct ogg_codec ff_vorbis_codec = {
.magic = "\001vorbis",
.magicsize = 7,
.header = vorbis_header
.header = vorbis_header,
.packet = vorbis_packet,
};
......@@ -26,6 +26,8 @@
* Options definition for AVFormatContext.
*/
#include "options_table.h"
static const char* format_to_name(void* ptr)
{
AVFormatContext* fc = (AVFormatContext*) ptr;
......@@ -74,54 +76,6 @@ static const AVClass *format_child_class_next(const AVClass *prev)
return NULL;
}
#define OFFSET(x) offsetof(AVFormatContext,x)
#define DEFAULT 0 //should be NAN but it does not work as it is not a constant in glibc as required by ANSI/ISO C
//these names are too long to be readable
#define E AV_OPT_FLAG_ENCODING_PARAM
#define D AV_OPT_FLAG_DECODING_PARAM
static const AVOption options[]={
{"probesize", "set probing size", OFFSET(probesize), AV_OPT_TYPE_INT, {.dbl = 5000000 }, 32, INT_MAX, D},
{"packetsize", "set packet size", OFFSET(packet_size), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, E},
{"fflags", NULL, OFFSET(flags), AV_OPT_TYPE_FLAGS, {.dbl = DEFAULT }, INT_MIN, INT_MAX, D|E, "fflags"},
{"ignidx", "ignore index", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_IGNIDX }, INT_MIN, INT_MAX, D, "fflags"},
{"genpts", "generate pts", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_GENPTS }, INT_MIN, INT_MAX, D, "fflags"},
{"nofillin", "do not fill in missing values that can be exactly calculated", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_NOFILLIN }, INT_MIN, INT_MAX, D, "fflags"},
{"noparse", "disable AVParsers, this needs nofillin too", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_NOPARSE }, INT_MIN, INT_MAX, D, "fflags"},
{"igndts", "ignore dts", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_IGNDTS }, INT_MIN, INT_MAX, D, "fflags"},
{"discardcorrupt", "discard corrupted frames", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_DISCARD_CORRUPT }, INT_MIN, INT_MAX, D, "fflags"},
{"sortdts", "try to interleave outputted packets by dts", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_SORT_DTS }, INT_MIN, INT_MAX, D, "fflags"},
{"keepside", "dont merge side data", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_KEEP_SIDE_DATA }, INT_MIN, INT_MAX, D, "fflags"},
{"latm", "enable RTP MP4A-LATM payload", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_MP4A_LATM }, INT_MIN, INT_MAX, E, "fflags"},
{"analyzeduration", "how many microseconds are analyzed to estimate duration", OFFSET(max_analyze_duration), AV_OPT_TYPE_INT, {.dbl = 5*AV_TIME_BASE }, 0, INT_MAX, D},
{"cryptokey", "decryption key", OFFSET(key), AV_OPT_TYPE_BINARY, {.dbl = 0}, 0, 0, D},
{"indexmem", "max memory used for timestamp index (per stream)", OFFSET(max_index_size), AV_OPT_TYPE_INT, {.dbl = 1<<20 }, 0, INT_MAX, D},
{"rtbufsize", "max memory used for buffering real-time frames", OFFSET(max_picture_buffer), AV_OPT_TYPE_INT, {.dbl = 3041280 }, 0, INT_MAX, D}, /* defaults to 1s of 15fps 352x288 YUYV422 video */
{"fdebug", "print specific debug info", OFFSET(debug), AV_OPT_TYPE_FLAGS, {.dbl = DEFAULT }, 0, INT_MAX, E|D, "fdebug"},
{"ts", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_FDEBUG_TS }, INT_MIN, INT_MAX, E|D, "fdebug"},
{"max_delay", "maximum muxing or demuxing delay in microseconds", OFFSET(max_delay), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, E|D},
{"fpsprobesize", "number of frames used to probe fps", OFFSET(fps_probe_size), AV_OPT_TYPE_INT, {.dbl = -1}, -1, INT_MAX-1, D},
{"audio_preload", "microseconds by which audio packets should be interleaved earlier", OFFSET(audio_preload), AV_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX-1, E},
{"chunk_duration", "microseconds for each chunk", OFFSET(max_chunk_duration), AV_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX-1, E},
{"chunk_size", "size in bytes for each chunk", OFFSET(max_chunk_size), AV_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX-1, E},
/* this is a crutch for avconv, since it cannot deal with identically named options in different contexts.
* to be removed when avconv is fixed */
{"f_err_detect", "set error detection flags (deprecated; use err_detect, save via avconv)", OFFSET(error_recognition), AV_OPT_TYPE_FLAGS, {.dbl = AV_EF_CRCCHECK }, INT_MIN, INT_MAX, D, "err_detect"},
{"err_detect", "set error detection flags", OFFSET(error_recognition), AV_OPT_TYPE_FLAGS, {.dbl = AV_EF_CRCCHECK }, INT_MIN, INT_MAX, D, "err_detect"},
{"crccheck", "verify embedded CRCs", 0, AV_OPT_TYPE_CONST, {.dbl = AV_EF_CRCCHECK }, INT_MIN, INT_MAX, D, "err_detect"},
{"bitstream", "detect bitstream specification deviations", 0, AV_OPT_TYPE_CONST, {.dbl = AV_EF_BITSTREAM }, INT_MIN, INT_MAX, D, "err_detect"},
{"buffer", "detect improper bitstream length", 0, AV_OPT_TYPE_CONST, {.dbl = AV_EF_BUFFER }, INT_MIN, INT_MAX, D, "err_detect"},
{"explode", "abort decoding on minor error detection", 0, AV_OPT_TYPE_CONST, {.dbl = AV_EF_EXPLODE }, INT_MIN, INT_MAX, D, "err_detect"},
{"careful", "consider things that violate the spec and have not been seen in the wild as errors", 0, AV_OPT_TYPE_CONST, {.dbl = AV_EF_CAREFUL }, INT_MIN, INT_MAX, D, "err_detect"},
{"compliant", "consider all spec non compliancies as errors", 0, AV_OPT_TYPE_CONST, {.dbl = AV_EF_COMPLIANT }, INT_MIN, INT_MAX, D, "err_detect"},
{"aggressive", "consider things that a sane encoder shouldnt do as an error", 0, AV_OPT_TYPE_CONST, {.dbl = AV_EF_AGGRESSIVE }, INT_MIN, INT_MAX, D, "err_detect"},
{NULL},
};
#undef E
#undef D
#undef DEFAULT
static const AVClass av_format_context_class = {
.class_name = "AVFormatContext",
.item_name = format_to_name,
......
/*
* Copyright (c) 2000, 2001, 2002 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 AVFORMAT_OPTIONS_TABLE
#define AVFORMAT_OPTIONS_TABLE
#define OFFSET(x) offsetof(AVFormatContext,x)
#define DEFAULT 0 //should be NAN but it does not work as it is not a constant in glibc as required by ANSI/ISO C
//these names are too long to be readable
#define E AV_OPT_FLAG_ENCODING_PARAM
#define D AV_OPT_FLAG_DECODING_PARAM
static const AVOption options[]={
{"probesize", "set probing size", OFFSET(probesize), AV_OPT_TYPE_INT, {.dbl = 5000000 }, 32, INT_MAX, D},
{"packetsize", "set packet size", OFFSET(packet_size), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, E},
{"fflags", NULL, OFFSET(flags), AV_OPT_TYPE_FLAGS, {.dbl = DEFAULT }, INT_MIN, INT_MAX, D|E, "fflags"},
{"ignidx", "ignore index", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_IGNIDX }, INT_MIN, INT_MAX, D, "fflags"},
{"genpts", "generate pts", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_GENPTS }, INT_MIN, INT_MAX, D, "fflags"},
{"nofillin", "do not fill in missing values that can be exactly calculated", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_NOFILLIN }, INT_MIN, INT_MAX, D, "fflags"},
{"noparse", "disable AVParsers, this needs nofillin too", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_NOPARSE }, INT_MIN, INT_MAX, D, "fflags"},
{"igndts", "ignore dts", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_IGNDTS }, INT_MIN, INT_MAX, D, "fflags"},
{"discardcorrupt", "discard corrupted frames", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_DISCARD_CORRUPT }, INT_MIN, INT_MAX, D, "fflags"},
{"sortdts", "try to interleave outputted packets by dts", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_SORT_DTS }, INT_MIN, INT_MAX, D, "fflags"},
{"keepside", "dont merge side data", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_KEEP_SIDE_DATA }, INT_MIN, INT_MAX, D, "fflags"},
{"latm", "enable RTP MP4A-LATM payload", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_MP4A_LATM }, INT_MIN, INT_MAX, E, "fflags"},
{"analyzeduration", "how many microseconds are analyzed to estimate duration", OFFSET(max_analyze_duration), AV_OPT_TYPE_INT, {.dbl = 5*AV_TIME_BASE }, 0, INT_MAX, D},
{"cryptokey", "decryption key", OFFSET(key), AV_OPT_TYPE_BINARY, {.dbl = 0}, 0, 0, D},
{"indexmem", "max memory used for timestamp index (per stream)", OFFSET(max_index_size), AV_OPT_TYPE_INT, {.dbl = 1<<20 }, 0, INT_MAX, D},
{"rtbufsize", "max memory used for buffering real-time frames", OFFSET(max_picture_buffer), AV_OPT_TYPE_INT, {.dbl = 3041280 }, 0, INT_MAX, D}, /* defaults to 1s of 15fps 352x288 YUYV422 video */
{"fdebug", "print specific debug info", OFFSET(debug), AV_OPT_TYPE_FLAGS, {.dbl = DEFAULT }, 0, INT_MAX, E|D, "fdebug"},
{"ts", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_FDEBUG_TS }, INT_MIN, INT_MAX, E|D, "fdebug"},
{"max_delay", "maximum muxing or demuxing delay in microseconds", OFFSET(max_delay), AV_OPT_TYPE_INT, {.dbl = -1 }, -1, INT_MAX, E|D},
{"fpsprobesize", "number of frames used to probe fps", OFFSET(fps_probe_size), AV_OPT_TYPE_INT, {.dbl = -1}, -1, INT_MAX-1, D},
{"audio_preload", "microseconds by which audio packets should be interleaved earlier", OFFSET(audio_preload), AV_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX-1, E},
{"chunk_duration", "microseconds for each chunk", OFFSET(max_chunk_duration), AV_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX-1, E},
{"chunk_size", "size in bytes for each chunk", OFFSET(max_chunk_size), AV_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX-1, E},
/* this is a crutch for avconv, since it cannot deal with identically named options in different contexts.
* to be removed when avconv is fixed */
{"f_err_detect", "set error detection flags (deprecated; use err_detect, save via avconv)", OFFSET(error_recognition), AV_OPT_TYPE_FLAGS, {.dbl = AV_EF_CRCCHECK }, INT_MIN, INT_MAX, D, "err_detect"},
{"err_detect", "set error detection flags", OFFSET(error_recognition), AV_OPT_TYPE_FLAGS, {.dbl = AV_EF_CRCCHECK }, INT_MIN, INT_MAX, D, "err_detect"},
{"crccheck", "verify embedded CRCs", 0, AV_OPT_TYPE_CONST, {.dbl = AV_EF_CRCCHECK }, INT_MIN, INT_MAX, D, "err_detect"},
{"bitstream", "detect bitstream specification deviations", 0, AV_OPT_TYPE_CONST, {.dbl = AV_EF_BITSTREAM }, INT_MIN, INT_MAX, D, "err_detect"},
{"buffer", "detect improper bitstream length", 0, AV_OPT_TYPE_CONST, {.dbl = AV_EF_BUFFER }, INT_MIN, INT_MAX, D, "err_detect"},
{"explode", "abort decoding on minor error detection", 0, AV_OPT_TYPE_CONST, {.dbl = AV_EF_EXPLODE }, INT_MIN, INT_MAX, D, "err_detect"},
{"careful", "consider things that violate the spec and have not been seen in the wild as errors", 0, AV_OPT_TYPE_CONST, {.dbl = AV_EF_CAREFUL }, INT_MIN, INT_MAX, D, "err_detect"},
{"compliant", "consider all spec non compliancies as errors", 0, AV_OPT_TYPE_CONST, {.dbl = AV_EF_COMPLIANT }, INT_MIN, INT_MAX, D, "err_detect"},
{"aggressive", "consider things that a sane encoder shouldnt do as an error", 0, AV_OPT_TYPE_CONST, {.dbl = AV_EF_AGGRESSIVE }, INT_MIN, INT_MAX, D, "err_detect"},
{NULL},
};
#undef E
#undef D
#undef DEFAULT
#undef OFFSET
#endif // AVFORMAT_OPTIONS_TABLE
......@@ -256,7 +256,7 @@ static int asfrtp_parse_packet(AVFormatContext *s, PayloadContext *asf,
for (;;) {
int i;
res = av_read_packet(rt->asf_ctx, pkt);
res = ff_read_packet(rt->asf_ctx, pkt);
rt->asf_pb_pos = avio_tell(pb);
if (res != 0)
break;
......
......@@ -126,7 +126,7 @@ static int rtp_write_header(AVFormatContext *s1)
s->max_payload_size = s1->packet_size - 12;
s->max_frames_per_packet = 0;
if (s1->max_delay) {
if (s1->max_delay > 0) {
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
int frame_size = av_get_audio_frame_duration(st->codec, 0);
if (!frame_size)
......
......@@ -56,6 +56,7 @@
#define MAX_TIMEOUTS READ_PACKET_TIMEOUT_S * 1000 / POLL_TIMEOUT_MS
#define SDP_MAX_SIZE 16384
#define RECVBUF_SIZE 10 * RTP_MAX_PACKET_LENGTH
#define DEFAULT_REORDERING_DELAY 100000
#define OFFSET(x) offsetof(RTSPState, x)
#define DEC AV_OPT_FLAG_DECODING_PARAM
......@@ -1421,6 +1422,9 @@ int ff_rtsp_connect(AVFormatContext *s)
if (!ff_network_init())
return AVERROR(EIO);
if (s->max_delay < 0) /* Not set by the caller */
s->max_delay = s->iformat ? DEFAULT_REORDERING_DELAY : 0;
rt->control_transport = RTSP_MODE_PLAIN;
if (rt->lower_transport_mask & (1 << RTSP_LOWER_TRANSPORT_HTTP)) {
rt->lower_transport_mask = 1 << RTSP_LOWER_TRANSPORT_TCP;
......@@ -1861,6 +1865,9 @@ static int sdp_read_header(AVFormatContext *s)
if (!ff_network_init())
return AVERROR(EIO);
if (s->max_delay < 0) /* Not set by the caller */
s->max_delay = DEFAULT_REORDERING_DELAY;
/* read the whole sdp file */
/* XXX: better loading */
content = av_malloc(SDP_MAX_SIZE);
......
......@@ -568,10 +568,22 @@ static AVPacket *add_to_pktbuf(AVPacketList **packet_buffer, AVPacket *pkt,
return &pktl->pkt;
}
static void queue_attached_pictures(AVFormatContext *s)
{
int i;
for (i = 0; i < s->nb_streams; i++)
if (s->streams[i]->disposition & AV_DISPOSITION_ATTACHED_PIC &&
s->streams[i]->discard < AVDISCARD_ALL) {
AVPacket copy = s->streams[i]->attached_pic;
copy.destruct = NULL;
add_to_pktbuf(&s->raw_packet_buffer, &copy, &s->raw_packet_buffer_end);
}
}
int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options)
{
AVFormatContext *s = *ps;
int i, ret = 0;
int ret = 0;
AVDictionary *tmp = NULL;
ID3v2ExtraMeta *id3v2_extra_meta = NULL;
......@@ -627,13 +639,7 @@ int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputForma
goto fail;
ff_id3v2_free_extra_meta(&id3v2_extra_meta);
/* queue attached pictures */
for (i = 0; i < s->nb_streams; i++)
if (s->streams[i]->disposition & AV_DISPOSITION_ATTACHED_PIC) {
AVPacket copy = s->streams[i]->attached_pic;
copy.destruct = NULL;
add_to_pktbuf(&s->raw_packet_buffer, &copy, &s->raw_packet_buffer_end);
}
queue_attached_pictures(s);
if (!(s->flags&AVFMT_FLAG_PRIV_OPT) && s->pb && !s->data_offset)
s->data_offset = avio_tell(s->pb);
......@@ -659,7 +665,7 @@ fail:
/*******************************************************/
int av_read_packet(AVFormatContext *s, AVPacket *pkt)
int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
{
int ret, i;
AVStream *st;
......@@ -756,6 +762,14 @@ int av_read_packet(AVFormatContext *s, AVPacket *pkt)
}
}
#if FF_API_READ_PACKET
int av_read_packet(AVFormatContext *s, AVPacket *pkt)
{
return ff_read_packet(s, pkt);
}
#endif
/**********************************************************/
static int determinable_frame_size(AVCodecContext *avctx)
......@@ -1228,7 +1242,7 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
AVPacket cur_pkt;
/* read next packet */
ret = av_read_packet(s, &cur_pkt);
ret = ff_read_packet(s, &cur_pkt);
if (ret < 0) {
if (ret == AVERROR(EAGAIN))
return ret;
......@@ -1255,7 +1269,7 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
cur_pkt.size);
}
if (s->debug & FF_FDEBUG_TS)
av_log(s, AV_LOG_DEBUG, "av_read_packet stream=%d, pts=%"PRId64", dts=%"PRId64", size=%d, duration=%d, flags=%d\n",
av_log(s, AV_LOG_DEBUG, "ff_read_packet stream=%d, pts=%"PRId64", dts=%"PRId64", size=%d, duration=%d, flags=%d\n",
cur_pkt.stream_index,
cur_pkt.pts,
cur_pkt.dts,
......@@ -1827,7 +1841,8 @@ static int seek_frame_generic(AVFormatContext *s,
return 0;
}
int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
static int seek_frame_internal(AVFormatContext *s, int stream_index,
int64_t timestamp, int flags)
{
int ret;
AVStream *st;
......@@ -1872,14 +1887,29 @@ int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int f
return -1;
}
int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
{
int ret = seek_frame_internal(s, stream_index, timestamp, flags);
if (ret >= 0)
queue_attached_pictures(s);
return ret;
}
int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
{
if(min_ts > ts || max_ts < ts)
return -1;
if (s->iformat->read_seek2) {
int ret;
ff_read_frame_flush(s);
return s->iformat->read_seek2(s, stream_index, min_ts, ts, max_ts, flags);
ret = s->iformat->read_seek2(s, stream_index, min_ts, ts, max_ts, flags);
if (ret >= 0)
queue_attached_pictures(s);
return ret;
}
if(s->iformat->read_timestamp){
......@@ -2071,7 +2101,7 @@ static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset)
break;
do {
ret = av_read_packet(ic, pkt);
ret = ff_read_packet(ic, pkt);
} while(ret == AVERROR(EAGAIN));
if (ret != 0)
break;
......@@ -3354,7 +3384,9 @@ static int ff_interleave_compare_dts(AVFormatContext *s, AVPacket *next, AVPacke
return comp > 0;
}
int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush){
int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out,
AVPacket *pkt, int flush)
{
AVPacketList *pktl;
int stream_count=0, noninterleaved_count=0;
int64_t delta_dts_max = 0;
......@@ -3413,6 +3445,14 @@ int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, AVPacket *pk
}
}
#if FF_API_INTERLEAVE_PACKET
int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out,
AVPacket *pkt, int flush)
{
return ff_interleave_packet_per_dts(s, out, pkt, flush);
}
#endif
/**
* Interleave an AVPacket correctly so it can be muxed.
* @param out the interleaved packet will be output here
......@@ -3429,7 +3469,7 @@ static int interleave_packet(AVFormatContext *s, AVPacket *out, AVPacket *in, in
av_free_packet(in);
return ret;
} else
return av_interleave_packet_per_dts(s, out, in, flush);
return ff_interleave_packet_per_dts(s, out, in, flush);
}
int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt){
......
......@@ -71,5 +71,11 @@
#ifndef FF_API_APPLEHTTP_PROTO
#define FF_API_APPLEHTTP_PROTO (LIBAVFORMAT_VERSION_MAJOR < 55)
#endif
#ifndef FF_API_READ_PACKET
#define FF_API_READ_PACKET (LIBAVFORMAT_VERSION_MAJOR < 55)
#endif
#ifndef FF_API_INTERLEAVE_PACKET
#define FF_API_INTERLEAVE_PACKET (LIBAVFORMAT_VERSION_MAJOR < 55)
#endif
#endif /* AVFORMAT_VERSION_H */
......@@ -38,7 +38,6 @@
typedef struct MaxisXADemuxContext {
uint32_t out_size;
uint32_t sent_bytes;
uint32_t audio_frame_counter;
} MaxisXADemuxContext;
static int xa_probe(AVProbeData *p)
......@@ -81,12 +80,15 @@ static int xa_read_header(AVFormatContext *s)
avio_skip(pb, 2); /* Skip the tag */
st->codec->channels = avio_rl16(pb);
st->codec->sample_rate = avio_rl32(pb);
/* Value in file is average byte rate*/
st->codec->bit_rate = avio_rl32(pb) * 8;
st->codec->block_align = avio_rl16(pb);
st->codec->bits_per_coded_sample = avio_rl16(pb);
avio_skip(pb, 4); /* Skip average byte rate */
avio_skip(pb, 2); /* Skip block align */
avio_skip(pb, 2); /* Skip bits-per-sample */
st->codec->bit_rate = av_clip(15LL * st->codec->channels * 8 *
st->codec->sample_rate / 28, 0, INT_MAX);
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
st->start_time = 0;
return 0;
}
......@@ -100,8 +102,8 @@ static int xa_read_packet(AVFormatContext *s,
unsigned int packet_size;
int ret;
if(xa->sent_bytes > xa->out_size)
return AVERROR(EIO);
if (xa->sent_bytes >= xa->out_size)
return AVERROR_EOF;
/* 1 byte header and 14 bytes worth of samples * number channels per block */
packet_size = 15*st->codec->channels;
......@@ -111,9 +113,7 @@ static int xa_read_packet(AVFormatContext *s,
pkt->stream_index = st->index;
xa->sent_bytes += packet_size;
pkt->pts = xa->audio_frame_counter;
/* 14 bytes Samples per channel with 2 samples per byte */
xa->audio_frame_counter += 28 * st->codec->channels;
pkt->duration = 28;
return ret;
}
......
......@@ -19,6 +19,9 @@ fate-adpcm-creative-8-4bit: CMD = md5 -i $(SAMPLES)/creative/BBC_4BIT.VOC -f s16
FATE_ADPCM += fate-adpcm-ea-mad-ea-r1
fate-adpcm-ea-mad-ea-r1: CMD = framecrc -i $(SAMPLES)/ea-mad/NFS6LogoE.mad
FATE_ADPCM += fate-adpcm-ea-maxis-xa
fate-adpcm-ea-maxis-xa: CMD = framecrc -i $(SAMPLES)/maxis-xa/SC2KBUG.XA -frames:a 30
FATE_ADPCM += fate-adpcm-ea-tqi
fate-adpcm-ea-tqi: CMD = framecrc -i $(SAMPLES)/ea-wve/networkBackbone-partial.wve -frames:v 26
......
......@@ -38,7 +38,7 @@ FATE_DEMUX += fate-lmlm4-demux
fate-lmlm4-demux: CMD = framecrc -i $(SAMPLES)/lmlm4/LMLM4_CIFat30fps.divx -t 3 -acodec copy -vcodec copy
FATE_DEMUX += fate-maxis-xa
fate-maxis-xa: CMD = md5 -i $(SAMPLES)/maxis-xa/SC2KBUG.XA -f s16le
fate-maxis-xa: CMD = framecrc -i $(SAMPLES)/maxis-xa/SC2KBUG.XA -frames:a 30 -c:a copy
FATE_DEMUX += fate-mtv
fate-mtv: CMD = framecrc -i $(SAMPLES)/mtv/comedian_auto-partial.mtv -acodec copy -pix_fmt rgb24
......
......@@ -41,6 +41,6 @@ fate-vp8-sign-bias$(1): REF = $(SRC_PATH)/tests/ref/fate/vp8-sign-bias
endef
$(eval $(call FATE_VP8_FULL))
$(eval $(call FATE_VP8_FULL,-emu-edge,-flags emu_edge))
$(eval $(call FATE_VP8_FULL,-emu-edge,-flags +emu_edge))
FATE_TESTS += $(FATE_VP8)
fate-vp8: $(FATE_VP8)
#tb 0: 1/22050
0, 0, 0, 28, 112, 0x291d1be4
0, 28, 28, 28, 112, 0xf08d33cc
0, 56, 56, 28, 112, 0x5b1521de
0, 84, 84, 28, 112, 0x57d209f6
0, 112, 112, 28, 112, 0x00000000
0, 140, 140, 28, 112, 0xa15e03fc
0, 168, 168, 28, 112, 0x73a80bf4
0, 196, 196, 28, 112, 0x916e03fc
0, 224, 224, 28, 112, 0xd92603fc
0, 252, 252, 28, 112, 0x097523dc
0, 280, 280, 28, 112, 0xf7be45ba
0, 308, 308, 28, 112, 0x0fed4db2
0, 336, 336, 28, 112, 0x9fb41be4
0, 364, 364, 28, 112, 0x819a0ff0
0, 392, 392, 28, 112, 0xfe7f3fc0
0, 420, 420, 28, 112, 0x281e1de2
0, 448, 448, 28, 112, 0xa76605fa
0, 476, 476, 28, 112, 0x00000000
0, 504, 504, 28, 112, 0xb84705fa
0, 532, 532, 28, 112, 0xdb5c0ff0
0, 560, 560, 28, 112, 0xbc4305fa
0, 588, 588, 28, 112, 0x7c8305fa
0, 616, 616, 28, 112, 0x54ff21de
0, 644, 644, 28, 112, 0xc6c535ca
0, 672, 672, 28, 112, 0xa4123dc2
0, 700, 700, 28, 112, 0x196523dc
0, 728, 728, 28, 112, 0x80ef25da
0, 756, 756, 28, 112, 0xdf742bd4
0, 784, 784, 28, 112, 0xd78a21de
0, 812, 812, 28, 112, 0x191f0df2
This diff is collapsed.
b4cd52fc080bffefeea94ce7c116046f
#tb 0: 1/22050
0, 0, 0, 28, 30, 0x51750711
0, 28, 28, 28, 30, 0x9ca20c2a
0, 56, 56, 28, 30, 0x7551081f
0, 84, 84, 28, 30, 0x09540063
0, 112, 112, 28, 30, 0x02c40018
0, 140, 140, 28, 30, 0x0f6c0117
0, 168, 168, 28, 30, 0x2aab0315
0, 196, 196, 28, 30, 0x0e6d0117
0, 224, 224, 28, 30, 0x04770036
0, 252, 252, 28, 30, 0x939c090f
0, 280, 280, 28, 30, 0xde511116
0, 308, 308, 28, 30, 0x2f0f13f5
0, 336, 336, 28, 30, 0x65bb0630
0, 364, 364, 28, 30, 0x1f7a0333
0, 392, 392, 28, 30, 0xa3d71008
0, 420, 420, 28, 30, 0x69120801
0, 448, 448, 28, 30, 0x1e7b0207
0, 476, 476, 28, 30, 0x02c40018
0, 504, 504, 28, 30, 0x0d050126
0, 532, 532, 28, 30, 0x41c10333
0, 560, 560, 28, 30, 0x16a10207
0, 588, 588, 28, 30, 0x0f210207
0, 616, 616, 28, 30, 0x4e4b073e
0, 644, 644, 28, 30, 0xa6f20d1a
0, 672, 672, 28, 30, 0xe1e40ff9
0, 700, 700, 28, 30, 0x868b090f
0, 728, 728, 28, 30, 0x8c85091e
0, 756, 756, 28, 30, 0x5a21094b
0, 784, 784, 28, 30, 0x993c0900
0, 812, 812, 28, 30, 0x5b6b04e6
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -16,31 +16,31 @@
0, 6, 6, 1, 69120, 0x433bb6f6
1, 18956, 18956, 2708, 10832, 0x88f5271a
0, 7, 7, 1, 69120, 0xdbac8bee
1, 21664, 21664, 2708, 10832, 0x55c6bbe5
1, 21665, 21665, 2708, 10832, 0x55c6bbe5
0, 8, 8, 1, 69120, 0x88e2a799
1, 24372, 24372, 2708, 10832, 0x9b51ae82
1, 24373, 24373, 2708, 10832, 0x9b51ae82
0, 9, 9, 1, 69120, 0x49617b26
1, 27080, 27080, 2708, 10832, 0xcdf2409b
1, 27081, 27081, 2708, 10832, 0xcdf2409b
0, 10, 10, 1, 69120, 0xeb44ca01
1, 29788, 29788, 2708, 10832, 0x0933b1a4
1, 29789, 29789, 2708, 10832, 0x0933b1a4
0, 11, 11, 1, 69120, 0x6fea37e8
1, 32496, 32496, 2708, 10832, 0x24b77006
1, 35204, 35204, 2708, 10832, 0xf612fa8a
1, 32497, 32497, 2708, 10832, 0x24b77006
1, 35205, 35205, 2708, 10832, 0xf612fa8a
0, 12, 12, 1, 69120, 0xf55d74c7
1, 37912, 37912, 2708, 10832, 0x99884b06
1, 37913, 37913, 2708, 10832, 0x99884b06
0, 13, 13, 1, 69120, 0xb5082ca7
1, 40620, 40620, 2708, 10832, 0x3c746fbe
1, 40621, 40621, 2708, 10832, 0x3c746fbe
0, 14, 14, 1, 69120, 0x5876d758
1, 43328, 43328, 2708, 10832, 0x05f3b08a
1, 43329, 43329, 2708, 10832, 0x05f3b08a
0, 15, 15, 1, 69120, 0x45e7dd5c
1, 46036, 46036, 2708, 10832, 0xa6560483
1, 48744, 48744, 2708, 10832, 0xd98a8e19
1, 51452, 51452, 2708, 10832, 0xf98a0b2e
1, 54160, 54160, 2708, 10832, 0xb1039582
1, 56868, 56868, 2708, 10832, 0x85dd5c3f
1, 59576, 59576, 2708, 10832, 0x19fc801a
1, 62284, 62284, 2708, 10832, 0x95805089
1, 64992, 64992, 2708, 10832, 0x576fdec3
1, 67700, 67700, 2708, 10832, 0x704a0905
1, 70408, 70408, 2708, 10832, 0xf87ce1fa
1, 73116, 73116, 2708, 10832, 0xfc0076b9
1, 46037, 46037, 2708, 10832, 0xa6560483
1, 48745, 48745, 2708, 10832, 0xd98a8e19
1, 51453, 51453, 2708, 10832, 0xf98a0b2e
1, 54161, 54161, 2708, 10832, 0xb1039582
1, 56869, 56869, 2708, 10832, 0x85dd5c3f
1, 59578, 59578, 2708, 10832, 0x19fc801a
1, 62286, 62286, 2708, 10832, 0x95805089
1, 64994, 64994, 2708, 10832, 0x576fdec3
1, 67702, 67702, 2708, 10832, 0x704a0905
1, 70410, 70410, 2708, 10832, 0xf87ce1fa
1, 73118, 73118, 2708, 10832, 0xfc0076b9
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