Compare commits
33 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 14e258d847 | |||
| ca47aec665 | |||
| 95e26d33d7 | |||
| f32051cd73 | |||
| c3ee5b4c36 | |||
| c17fd9f9ce | |||
| 0f3cdddf38 | |||
| a0d13f578b | |||
| 91e19ab930 | |||
| bb4126e250 | |||
| 9902eef0f5 | |||
| 6db67ac2a4 | |||
| 85eeab4d22 | |||
| 4431ee1896 | |||
| d2feaf2ba6 | |||
| 0f73cb454d | |||
| 82cfb8c2db | |||
| 0a55c882cb | |||
| c09acf9882 | |||
| a0779a2ee5 | |||
| b4f90013ab | |||
| 3a6fbb0c8e | |||
| 6a782e20d7 | |||
| 8cea63c48a | |||
| 8f87e75c6c | |||
| 06a927a6b5 | |||
| 3c523bdda8 | |||
| ece54c7085 | |||
| 7eee79ea2f | |||
| 458933fdb8 | |||
| 95d0baa952 | |||
| 32cff0d3f0 | |||
| ddce97c7b0 |
+1
-1
@@ -31,7 +31,7 @@ PROJECT_NAME = FFmpeg
|
||||
# This could be handy for archiving the generated documentation or
|
||||
# if some version control system is used.
|
||||
|
||||
PROJECT_NUMBER = 1.2.3
|
||||
PROJECT_NUMBER = 1.2.4
|
||||
|
||||
# With the PROJECT_LOGO tag one can specify an logo or icon that is included
|
||||
# in the documentation. The maximum height of the logo should not exceed 55
|
||||
|
||||
+149
-48
@@ -25,6 +25,95 @@ enabled encoders.
|
||||
A description of some of the currently available audio encoders
|
||||
follows.
|
||||
|
||||
@anchor{aacenc}
|
||||
@section aac
|
||||
|
||||
Advanced Audio Coding (AAC) encoder.
|
||||
|
||||
This encoder is an experimental FFmpeg-native AAC encoder. Currently only the
|
||||
low complexity (AAC-LC) profile is supported. To use this encoder, you must set
|
||||
@option{strict} option to @samp{experimental} or lower.
|
||||
|
||||
As this encoder is experimental, unexpected behavior may exist from time to
|
||||
time. For a more stable AAC encoder, see @ref{libvo-aacenc}. However, be warned
|
||||
that it has a worse quality reported by some users.
|
||||
|
||||
@c Comment this out until somebody writes the respective documentation.
|
||||
@c See also @ref{libfaac}, @ref{libaacplus}, and @ref{libfdk-aac-enc}.
|
||||
|
||||
@subsection Options
|
||||
|
||||
@table @option
|
||||
@item b
|
||||
Set bit rate in bits/s. Setting this automatically activates constant bit rate
|
||||
(CBR) mode.
|
||||
|
||||
@item q
|
||||
Set quality for variable bit rate (VBR) mode. This option is valid only using
|
||||
the @command{ffmpeg} command-line tool. For library interface users, use
|
||||
@option{global_quality}.
|
||||
|
||||
@item stereo_mode
|
||||
Set stereo encoding mode. Possible values:
|
||||
|
||||
@table @samp
|
||||
@item auto
|
||||
Automatically selected by the encoder.
|
||||
|
||||
@item ms_off
|
||||
Disable middle/side encoding. This is the default.
|
||||
|
||||
@item ms_force
|
||||
Force middle/side encoding.
|
||||
@end table
|
||||
|
||||
@item aac_coder
|
||||
Set AAC encoder coding method. Possible values:
|
||||
|
||||
@table @samp
|
||||
@item 0
|
||||
FAAC-inspired method.
|
||||
|
||||
This method is a simplified reimplementation of the method used in FAAC, which
|
||||
sets thresholds proportional to the band energies, and then decreases all the
|
||||
thresholds with quantizer steps to find the appropriate quantization with
|
||||
distortion below threshold band by band.
|
||||
|
||||
The quality of this method is comparable to the two loop searching method
|
||||
descibed below, but somewhat a little better and slower.
|
||||
|
||||
@item 1
|
||||
Average noise to mask ratio (ANMR) trellis-based solution.
|
||||
|
||||
This has a theoretic best quality out of all the coding methods, but at the
|
||||
cost of the slowest speed.
|
||||
|
||||
@item 2
|
||||
Two loop searching (TLS) method.
|
||||
|
||||
This method first sets quantizers depending on band thresholds and then tries
|
||||
to find an optimal combination by adding or subtracting a specific value from
|
||||
all quantizers and adjusting some individual quantizer a little.
|
||||
|
||||
This method produces similar quality with the FAAC method and is the default.
|
||||
|
||||
@item 3
|
||||
Constant quantizer method.
|
||||
|
||||
This method sets a constant quantizer for all bands. This is the fastest of all
|
||||
the methods, yet produces the worst quality.
|
||||
|
||||
@end table
|
||||
|
||||
@end table
|
||||
|
||||
@subsection Tips and Tricks
|
||||
|
||||
According to some reports
|
||||
(e.g. @url{http://d.hatena.ne.jp/kamedo2/20120729/1343545890}), setting the
|
||||
@option{cutoff} option to 15000 Hz greatly improves the quality of the output
|
||||
quality. As a result, we encourage you to do the same.
|
||||
|
||||
@section ac3 and ac3_fixed
|
||||
|
||||
AC-3 audio encoders.
|
||||
@@ -420,26 +509,32 @@ Requires the presence of the libmp3lame headers and library during
|
||||
configuration. You need to explicitly configure the build with
|
||||
@code{--enable-libmp3lame}.
|
||||
|
||||
@subsection Option Mapping
|
||||
@subsection Options
|
||||
|
||||
The following options are supported by the libmp3lame wrapper,
|
||||
the LAME-equivalent options follow the FFmpeg ones.
|
||||
The following options are supported by the libmp3lame wrapper. The
|
||||
@command{lame}-equivalent of the options are listed in parentheses.
|
||||
|
||||
@multitable @columnfractions .2 .2
|
||||
@item FFmpeg @tab LAME
|
||||
@item b @tab b
|
||||
FFmpeg @code{b} option is expressed in bits/s, lame @code{bitrate}
|
||||
in kilobits/s.
|
||||
@item q @tab V
|
||||
Quality setting for VBR.
|
||||
@item compression_level @tab q
|
||||
Algorithm quality. Valid options are integers from 0-9.
|
||||
@item reservoir @tab N.A.
|
||||
Enable use of bit reservoir. LAME has this enabled by default.
|
||||
@item joint_stereo @tab -m j
|
||||
Enables the the encoder to use (on a frame by frame basis) either L/R
|
||||
stereo or mid/side stereo.
|
||||
@end multitable
|
||||
@table @option
|
||||
@item b (@emph{-b})
|
||||
Set bitrate expressed in bits/s for CBR. LAME @code{bitrate} is
|
||||
expressed in kilobits/s.
|
||||
|
||||
@item q (@emph{-V})
|
||||
Set constant quality setting for VBR. This option is valid only
|
||||
using the @command{ffmpeg} command-line tool. For library interface
|
||||
users, use @option{global_quality}.
|
||||
|
||||
@item compression_level (@emph{-q})
|
||||
Set algorithm quality. Valid arguments are integers in the 0-9 range,
|
||||
with 0 meaning highest quality but slowest, and 9 meaning fastest
|
||||
while producing the worst quality.
|
||||
|
||||
@item reservoir
|
||||
Enable use of bit reservoir when set to 1. Default value is 1. LAME
|
||||
has this enabled by default, but can be overriden by use
|
||||
@option{--nores} option.
|
||||
|
||||
@end table
|
||||
|
||||
@section libopencore-amrnb
|
||||
|
||||
@@ -486,24 +581,26 @@ Requires the presence of the libtwolame headers and library during
|
||||
configuration. You need to explicitly configure the build with
|
||||
@code{--enable-libtwolame}.
|
||||
|
||||
@subsection Options Mapping
|
||||
@subsection Options
|
||||
|
||||
The following options are supported by the libtwolame wrapper. The
|
||||
TwoLAME-equivalent options follow the FFmpeg ones and are in
|
||||
@command{twolame}-equivalent options follow the FFmpeg ones and are in
|
||||
parentheses.
|
||||
|
||||
@table @option
|
||||
@item b
|
||||
(b) Set bitrate in bits/s. Note that FFmpeg @code{b} option is
|
||||
expressed in bits/s, twolame @code{b} in kilobits/s. The default
|
||||
value is 128k.
|
||||
@item b (@emph{-b})
|
||||
Set bitrate expressed in bits/s for CBR. @command{twolame} @option{b}
|
||||
option is expressed in kilobits/s. Default value is 128k.
|
||||
|
||||
@item q
|
||||
(V) Set quality for experimental VBR support. Maximum value range is
|
||||
from -50 to 50, useful range is from -10 to 10.
|
||||
@item q (@emph{-V})
|
||||
Set quality for experimental VBR support. Maximum value range is
|
||||
from -50 to 50, useful range is from -10 to 10. The higher the
|
||||
value, the better the quality. This option is valid only using the
|
||||
@command{ffmpeg} command-line tool. For library interface users,
|
||||
use @option{global_quality}.
|
||||
|
||||
@item mode
|
||||
(mode) Set MPEG mode. Possible values:
|
||||
@item mode (@emph{--mode})
|
||||
Set the mode of the resulting audio. Possible values:
|
||||
|
||||
@table @samp
|
||||
@item auto
|
||||
@@ -518,29 +615,30 @@ Dual channel
|
||||
Mono
|
||||
@end table
|
||||
|
||||
@item psymodel
|
||||
(psyc-mode) Set psychoacoustic model to use in encoding. The argument
|
||||
must be an integer between -1 and 4, inclusive. The higher the value,
|
||||
the better the quality. The default value is 3.
|
||||
@item psymodel (@emph{--psyc-mode})
|
||||
Set psychoacoustic model to use in encoding. The argument must be
|
||||
an integer between -1 and 4, inclusive. The higher the value, the
|
||||
better the quality. The default value is 3.
|
||||
|
||||
@item energy_levels
|
||||
(energy) Enable energy levels extensions when set to 1. The default
|
||||
value is 0 (disabled).
|
||||
@item energy_levels (@emph{--energy})
|
||||
Enable energy levels extensions when set to 1. The default value is
|
||||
0 (disabled).
|
||||
|
||||
@item error_protection
|
||||
(protect) Enable CRC error protection when set to 1. The default value
|
||||
is 0 (disabled).
|
||||
@item error_protection (@emph{--protect})
|
||||
Enable CRC error protection when set to 1. The default value is 0
|
||||
(disabled).
|
||||
|
||||
@item copyright
|
||||
(copyright) Set MPEG audio copyright flag when set to 1. The default
|
||||
value is 0 (disabled).
|
||||
@item copyright (@emph{--copyright})
|
||||
Set MPEG audio copyright flag when set to 1. The default value is 0
|
||||
(disabled).
|
||||
|
||||
@item original
|
||||
(original) Set MPEG audio original flag when set to 1. The default
|
||||
value is 0 (disabled).
|
||||
@item original (@emph{--original})
|
||||
Set MPEG audio original flag when set to 1. The default value is 0
|
||||
(disabled).
|
||||
|
||||
@end table
|
||||
|
||||
@anchor{libvo-aacenc}
|
||||
@section libvo-aacenc
|
||||
|
||||
VisualOn AAC encoder
|
||||
@@ -549,16 +647,19 @@ Requires the presence of the libvo-aacenc headers and library during
|
||||
configuration. You need to explicitly configure the build with
|
||||
@code{--enable-libvo-aacenc --enable-version3}.
|
||||
|
||||
This encoder is considered to be worse than the
|
||||
@ref{aacenc,,native experimental FFmpeg AAC encoder}, according to
|
||||
multiple sources.
|
||||
|
||||
@subsection Options
|
||||
|
||||
The VisualOn AAC encoder only support encoding AAC-LC and up to 2
|
||||
channels. It is also CBR-only. It is considered to be worse than the
|
||||
native experimental FFmpeg AAC encoder.
|
||||
channels. It is also CBR-only.
|
||||
|
||||
@table @option
|
||||
|
||||
@item b
|
||||
Bitrate.
|
||||
Set bit rate in bits/s.
|
||||
|
||||
@end table
|
||||
|
||||
|
||||
@@ -76,6 +76,9 @@ Enable RTP MP4A-LATM payload.
|
||||
Reduce the latency introduced by optional buffering
|
||||
@end table
|
||||
|
||||
@item seek2any @var{integer} (@emph{input})
|
||||
Forces seeking to enable seek to any mode if set to 1. Default is 0.
|
||||
|
||||
@item analyzeduration @var{integer} (@emph{input})
|
||||
Specify how many microseconds are analyzed to probe the input. A
|
||||
higher value will allow to detect more accurate information, but will
|
||||
@@ -142,6 +145,12 @@ Use wallclock as timestamps.
|
||||
@item avoid_negative_ts @var{integer} (@emph{output})
|
||||
Shift timestamps to make them positive. 1 enables, 0 disables, default
|
||||
of -1 enables when required by target format.
|
||||
|
||||
@item skip_initial_bytes @var{integer} (@emph{input})
|
||||
Set number initial bytes to skip. Default is 0.
|
||||
|
||||
@item correct_ts_overflow @var{integer} (@emph{input})
|
||||
Correct single timestamp overflows if set to 1. Default is 1.
|
||||
@end table
|
||||
|
||||
@c man end FORMAT OPTIONS
|
||||
|
||||
@@ -1897,7 +1897,7 @@ void ff_set_cmp(DSPContext* c, me_cmp_func *cmp, int type){
|
||||
|
||||
static void add_bytes_c(uint8_t *dst, uint8_t *src, int w){
|
||||
long i;
|
||||
for(i=0; i<=w-sizeof(long); i+=sizeof(long)){
|
||||
for(i=0; i<=w-(int)sizeof(long); i+=sizeof(long)){
|
||||
long a = *(long*)(src+i);
|
||||
long b = *(long*)(dst+i);
|
||||
*(long*)(dst+i) = ((a&pb_7f) + (b&pb_7f)) ^ ((a^b)&pb_80);
|
||||
@@ -1922,7 +1922,7 @@ static void diff_bytes_c(uint8_t *dst, const uint8_t *src1, const uint8_t *src2,
|
||||
}
|
||||
}else
|
||||
#endif
|
||||
for(i=0; i<=w-sizeof(long); i+=sizeof(long)){
|
||||
for(i=0; i<=w-(int)sizeof(long); i+=sizeof(long)){
|
||||
long a = *(long*)(src1+i);
|
||||
long b = *(long*)(src2+i);
|
||||
*(long*)(dst+i) = ((a|pb_80) - (b&pb_7f)) ^ ((a^b^pb_80)&pb_80);
|
||||
|
||||
+29
-7
@@ -446,6 +446,10 @@ static int read_extra_header(FFV1Context *f)
|
||||
ff_build_rac_states(c, 0.05 * (1LL << 32), 256 - 8);
|
||||
|
||||
f->version = get_symbol(c, state, 0);
|
||||
if (f->version < 2) {
|
||||
av_log(f->avctx, AV_LOG_ERROR, "Invalid version in global header\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
if (f->version > 2) {
|
||||
c->bytestream_end -= 4;
|
||||
f->minor_version = get_symbol(c, state, 0);
|
||||
@@ -523,6 +527,7 @@ static int read_header(FFV1Context *f)
|
||||
memset(state, 128, sizeof(state));
|
||||
|
||||
if (f->version < 2) {
|
||||
int chroma_planes, chroma_h_shift, chroma_v_shift, transparency, colorspace, bits_per_raw_sample;
|
||||
unsigned v= get_symbol(c, state, 0);
|
||||
if (v >= 2) {
|
||||
av_log(f->avctx, AV_LOG_ERROR, "invalid version %d in ver01 header\n", v);
|
||||
@@ -535,15 +540,32 @@ static int read_header(FFV1Context *f)
|
||||
f->state_transition[i] = get_symbol(c, state, 1) + c->one_state[i];
|
||||
}
|
||||
|
||||
f->colorspace = get_symbol(c, state, 0); //YUV cs type
|
||||
colorspace = get_symbol(c, state, 0); //YUV cs type
|
||||
bits_per_raw_sample = f->version > 0 ? get_symbol(c, state, 0) : f->avctx->bits_per_raw_sample;
|
||||
chroma_planes = get_rac(c, state);
|
||||
chroma_h_shift = get_symbol(c, state, 0);
|
||||
chroma_v_shift = get_symbol(c, state, 0);
|
||||
transparency = get_rac(c, state);
|
||||
|
||||
if (f->version > 0)
|
||||
f->avctx->bits_per_raw_sample = get_symbol(c, state, 0);
|
||||
if (f->plane_count) {
|
||||
if ( colorspace != f->colorspace
|
||||
|| bits_per_raw_sample != f->avctx->bits_per_raw_sample
|
||||
|| chroma_planes != f->chroma_planes
|
||||
|| chroma_h_shift!= f->chroma_h_shift
|
||||
|| chroma_v_shift!= f->chroma_v_shift
|
||||
|| transparency != f->transparency) {
|
||||
av_log(f->avctx, AV_LOG_ERROR, "Invalid change of global parameters\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
}
|
||||
|
||||
f->colorspace = colorspace;
|
||||
f->avctx->bits_per_raw_sample = bits_per_raw_sample;
|
||||
f->chroma_planes = chroma_planes;
|
||||
f->chroma_h_shift = chroma_h_shift;
|
||||
f->chroma_v_shift = chroma_v_shift;
|
||||
f->transparency = transparency;
|
||||
|
||||
f->chroma_planes = get_rac(c, state);
|
||||
f->chroma_h_shift = get_symbol(c, state, 0);
|
||||
f->chroma_v_shift = get_symbol(c, state, 0);
|
||||
f->transparency = get_rac(c, state);
|
||||
f->plane_count = 2 + f->transparency;
|
||||
}
|
||||
|
||||
|
||||
@@ -274,7 +274,7 @@ static av_always_inline int encode_line(FFV1Context *s, int w,
|
||||
int run_mode = 0;
|
||||
|
||||
if (s->ac) {
|
||||
if (c->bytestream_end - c->bytestream < w * 20) {
|
||||
if (c->bytestream_end - c->bytestream < w * 35) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
+1
-1
@@ -3775,6 +3775,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
|
||||
|
||||
if (h->ref_count[0]) h->er.last_pic = &h->ref_list[0][0];
|
||||
if (h->ref_count[1]) h->er.next_pic = &h->ref_list[1][0];
|
||||
h->er.ref_count = h->ref_count[0];
|
||||
|
||||
if (h->avctx->debug & FF_DEBUG_PICT_INFO) {
|
||||
av_log(h->avctx, AV_LOG_DEBUG,
|
||||
@@ -4166,7 +4167,6 @@ static void er_add_slice(H264Context *h, int startx, int starty,
|
||||
if (CONFIG_ERROR_RESILIENCE) {
|
||||
ERContext *er = &h->er;
|
||||
|
||||
er->ref_count = h->ref_count[0];
|
||||
ff_er_add_slice(er, startx, starty, endx, endy, status);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -774,6 +774,12 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, int nb_components, int p
|
||||
int resync_mb_y = 0;
|
||||
int resync_mb_x = 0;
|
||||
|
||||
if (s->nb_components != 3 && s->nb_components != 4)
|
||||
return AVERROR_INVALIDDATA;
|
||||
if (s->v_max != 1 || s->h_max != 1 || !s->lossless)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
|
||||
s->restart_count = s->restart_interval;
|
||||
|
||||
av_fast_malloc(&s->ljpeg_buffer, &s->ljpeg_buffer_size,
|
||||
|
||||
+7
-3
@@ -235,8 +235,10 @@ int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_s
|
||||
if(next == END_NOT_FOUND){
|
||||
void* new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, (*buf_size) + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
|
||||
if(!new_buffer)
|
||||
if(!new_buffer) {
|
||||
pc->index = 0;
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
pc->buffer = new_buffer;
|
||||
memcpy(&pc->buffer[pc->index], *buf, *buf_size);
|
||||
pc->index += *buf_size;
|
||||
@@ -249,9 +251,11 @@ int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_s
|
||||
/* append to buffer */
|
||||
if(pc->index){
|
||||
void* new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, next + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
|
||||
if(!new_buffer)
|
||||
if(!new_buffer) {
|
||||
pc->overread_index =
|
||||
pc->index = 0;
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
pc->buffer = new_buffer;
|
||||
if (next > -FF_INPUT_BUFFER_PADDING_SIZE)
|
||||
memcpy(&pc->buffer[pc->index], *buf,
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@
|
||||
static void add_bytes_l2_c(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w)
|
||||
{
|
||||
long i;
|
||||
for (i = 0; i <= w - sizeof(long); i += sizeof(long)) {
|
||||
for (i = 0; i <= w - (int)sizeof(long); i += sizeof(long)) {
|
||||
long a = *(long *)(src1 + i);
|
||||
long b = *(long *)(src2 + i);
|
||||
*(long *)(dst + i) = ((a & pb_7f) + (b & pb_7f)) ^ ((a ^ b) & pb_80);
|
||||
|
||||
+2
-1
@@ -204,7 +204,8 @@ static const char *read_ts(const char *buf, int *ts_start, int *ts_end,
|
||||
"%*[ ]X1:%u X2:%u Y1:%u Y2:%u",
|
||||
&hs, &ms, &ss, ts_start, &he, &me, &se, ts_end,
|
||||
x1, x2, y1, y2);
|
||||
buf += strcspn(buf, "\n") + 1;
|
||||
buf += strcspn(buf, "\n");
|
||||
buf += !!*buf;
|
||||
if (c >= 8) {
|
||||
*ts_start = 100*(ss + 60*(ms + 60*hs)) + *ts_start/10;
|
||||
*ts_end = 100*(se + 60*(me + 60*he)) + *ts_end /10;
|
||||
|
||||
@@ -948,14 +948,14 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
||||
if (!l->Y1_base || !l->Y2_base || !l->U1_base ||
|
||||
!l->V1_base || !l->U2_base || !l->V2_base ||
|
||||
!l->last || !l->clast) {
|
||||
av_freep(l->Y1_base);
|
||||
av_freep(l->Y2_base);
|
||||
av_freep(l->U1_base);
|
||||
av_freep(l->U2_base);
|
||||
av_freep(l->V1_base);
|
||||
av_freep(l->V2_base);
|
||||
av_freep(l->last);
|
||||
av_freep(l->clast);
|
||||
av_freep(&l->Y1_base);
|
||||
av_freep(&l->Y2_base);
|
||||
av_freep(&l->U1_base);
|
||||
av_freep(&l->U2_base);
|
||||
av_freep(&l->V1_base);
|
||||
av_freep(&l->V2_base);
|
||||
av_freep(&l->last);
|
||||
av_freep(&l->clast);
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
l->Y1 = l->Y1_base + l->y_stride * 4 + 4;
|
||||
|
||||
@@ -506,6 +506,10 @@ static int wma_decode_block(WMACodecContext *s)
|
||||
coef escape coding */
|
||||
total_gain = 1;
|
||||
for(;;) {
|
||||
if (get_bits_left(&s->gb) < 7) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "total_gain overread\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
a = get_bits(&s->gb, 7);
|
||||
total_gain += a;
|
||||
if (a != 127)
|
||||
|
||||
@@ -985,6 +985,9 @@ static int v4l2_read_header(AVFormatContext *s1)
|
||||
if (codec_id == AV_CODEC_ID_RAWVIDEO)
|
||||
st->codec->codec_tag =
|
||||
avcodec_pix_fmt_to_codec_tag(st->codec->pix_fmt);
|
||||
else if (codec_id == AV_CODEC_ID_H264) {
|
||||
st->need_parsing = AVSTREAM_PARSE_HEADERS;
|
||||
}
|
||||
if (desired_format == V4L2_PIX_FMT_YVU420)
|
||||
st->codec->codec_tag = MKTAG('Y', 'V', '1', '2');
|
||||
else if (desired_format == V4L2_PIX_FMT_YVU410)
|
||||
|
||||
@@ -203,7 +203,7 @@ static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *buf)
|
||||
}
|
||||
|
||||
/* now wait for the next timestamp */
|
||||
if (buf->pts == AV_NOPTS_VALUE) {
|
||||
if (buf->pts == AV_NOPTS_VALUE || av_fifo_size(s->fifo) <= 0) {
|
||||
return write_to_fifo(s->fifo, buf);
|
||||
}
|
||||
|
||||
|
||||
@@ -1303,7 +1303,7 @@ static int avi_read_idx1(AVFormatContext *s, int size)
|
||||
st = s->streams[index];
|
||||
ast = st->priv_data;
|
||||
|
||||
if(first_packet && first_packet_pos && len) {
|
||||
if (first_packet && first_packet_pos) {
|
||||
data_offset = first_packet_pos - pos;
|
||||
first_packet = 0;
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ static int jacosub_probe(AVProbeData *p)
|
||||
return AVPROBE_SCORE_MAX/2 + 1;
|
||||
return 0;
|
||||
}
|
||||
ptr += strcspn(ptr, "\n") + 1;
|
||||
ptr += ff_subtitles_next_line(ptr);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -258,6 +258,7 @@ static int lxf_read_header(AVFormatContext *s)
|
||||
st->codec->bit_rate = 1000000 * ((video_params >> 14) & 0xFF);
|
||||
st->codec->codec_tag = video_params & 0xF;
|
||||
st->codec->codec_id = ff_codec_get_id(lxf_tags, st->codec->codec_tag);
|
||||
st->need_parsing = AVSTREAM_PARSE_HEADERS;
|
||||
|
||||
av_log(s, AV_LOG_DEBUG, "record: %x = %i-%02i-%02i\n",
|
||||
record_date, 1900 + (record_date & 0x7F), (record_date >> 7) & 0xF,
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "avc.h"
|
||||
#include "flacenc.h"
|
||||
#include "avlanguage.h"
|
||||
#include "subtitles.h"
|
||||
#include "libavutil/samplefmt.h"
|
||||
#include "libavutil/sha.h"
|
||||
#include "libavutil/intreadwrite.h"
|
||||
@@ -1179,7 +1180,7 @@ static int srt_get_duration(uint8_t **buf)
|
||||
s_hsec += 1000*s_sec; e_hsec += 1000*e_sec;
|
||||
duration = e_hsec - s_hsec;
|
||||
}
|
||||
*buf += strcspn(*buf, "\n") + 1;
|
||||
*buf += ff_subtitles_next_line(*buf);
|
||||
}
|
||||
return duration;
|
||||
}
|
||||
@@ -1414,7 +1415,6 @@ const AVCodecTag additional_audio_tags[] = {
|
||||
};
|
||||
|
||||
const AVCodecTag additional_video_tags[] = {
|
||||
{ AV_CODEC_ID_PRORES, 0xFFFFFFFF },
|
||||
{ AV_CODEC_ID_RV10, 0xFFFFFFFF },
|
||||
{ AV_CODEC_ID_RV20, 0xFFFFFFFF },
|
||||
{ AV_CODEC_ID_RV30, 0xFFFFFFFF },
|
||||
|
||||
@@ -47,7 +47,7 @@ static int microdvd_probe(AVProbeData *p)
|
||||
sscanf(ptr, "{%*d}{%*d}%c", &c) != 1 &&
|
||||
sscanf(ptr, "{DEFAULT}{}%c", &c) != 1)
|
||||
return 0;
|
||||
ptr += strcspn(ptr, "\n") + 1;
|
||||
ptr += ff_subtitles_next_line(ptr);
|
||||
}
|
||||
return AVPROBE_SCORE_MAX;
|
||||
}
|
||||
|
||||
@@ -649,6 +649,7 @@ static int vobsub_read_header(AVFormatContext *s)
|
||||
st->id = stream_id;
|
||||
st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
|
||||
st->codec->codec_id = AV_CODEC_ID_DVD_SUBTITLE;
|
||||
avpriv_set_pts_info(st, 64, 1, 1000);
|
||||
av_dict_set(&st->metadata, "language", id, 0);
|
||||
av_log(s, AV_LOG_DEBUG, "IDX stream[%d] id=%s\n", stream_id, id);
|
||||
header_parsed = 1;
|
||||
@@ -806,6 +807,21 @@ static int vobsub_read_seek(AVFormatContext *s, int stream_index,
|
||||
int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
|
||||
{
|
||||
MpegDemuxContext *vobsub = s->priv_data;
|
||||
|
||||
/* Rescale requested timestamps based on the first stream (timebase is the
|
||||
* same for all subtitles stream within a .idx/.sub). Rescaling is done just
|
||||
* like in avformat_seek_file(). */
|
||||
if (stream_index == -1 && s->nb_streams != 1) {
|
||||
AVRational time_base = s->streams[0]->time_base;
|
||||
ts = av_rescale_q(ts, AV_TIME_BASE_Q, time_base);
|
||||
min_ts = av_rescale_rnd(min_ts, time_base.den,
|
||||
time_base.num * (int64_t)AV_TIME_BASE,
|
||||
AV_ROUND_UP | AV_ROUND_PASS_MINMAX);
|
||||
max_ts = av_rescale_rnd(max_ts, time_base.den,
|
||||
time_base.num * (int64_t)AV_TIME_BASE,
|
||||
AV_ROUND_DOWN | AV_ROUND_PASS_MINMAX);
|
||||
}
|
||||
|
||||
return ff_subtitles_queue_seek(&vobsub->q, s, stream_index,
|
||||
min_ts, ts, max_ts, flags);
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ static int mpl2_probe(AVProbeData *p)
|
||||
if (sscanf(ptr, "[%"PRId64"][%"PRId64"]%c", &start, &end, &c) != 3 &&
|
||||
sscanf(ptr, "[%"PRId64"][]%c", &start, &c) != 2)
|
||||
return 0;
|
||||
ptr += strcspn(ptr, "\r\n") + 1;
|
||||
ptr += ff_subtitles_next_line(ptr);
|
||||
if (ptr >= ptr_end)
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -37,12 +37,16 @@ static int mpsub_probe(AVProbeData *p)
|
||||
const char *ptr_end = p->buf + p->buf_size;
|
||||
|
||||
while (ptr < ptr_end) {
|
||||
int inc;
|
||||
int n;
|
||||
|
||||
if (!memcmp(ptr, "FORMAT=TIME", 11) ||
|
||||
sscanf(ptr, "FORMAT=%d", &n) == 1)
|
||||
return AVPROBE_SCORE_MAX/2;
|
||||
ptr += strcspn(ptr, "\n") + 1;
|
||||
inc = ff_subtitles_next_line(ptr);
|
||||
if (!inc)
|
||||
break;
|
||||
ptr += inc;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
+10
-6
@@ -76,6 +76,7 @@ typedef struct {
|
||||
int temporal_reordering;
|
||||
AVRational aspect_ratio; ///< display aspect ratio
|
||||
int closed_gop; ///< gop is closed, used in mpeg-2 frame parsing
|
||||
int video_bit_rate;
|
||||
} MXFStreamContext;
|
||||
|
||||
typedef struct {
|
||||
@@ -976,13 +977,14 @@ static void mxf_write_cdci_desc(AVFormatContext *s, AVStream *st)
|
||||
static void mxf_write_mpegvideo_desc(AVFormatContext *s, AVStream *st)
|
||||
{
|
||||
AVIOContext *pb = s->pb;
|
||||
MXFStreamContext *sc = st->priv_data;
|
||||
int profile_and_level = (st->codec->profile<<4) | st->codec->level;
|
||||
|
||||
mxf_write_cdci_common(s, st, mxf_mpegvideo_descriptor_key, 8+5);
|
||||
|
||||
// bit rate
|
||||
mxf_write_local_tag(pb, 4, 0x8000);
|
||||
avio_wb32(pb, st->codec->bit_rate);
|
||||
avio_wb32(pb, sc->video_bit_rate);
|
||||
|
||||
// profile and level
|
||||
mxf_write_local_tag(pb, 1, 0x8007);
|
||||
@@ -1705,14 +1707,15 @@ static int mxf_write_header(AVFormatContext *s)
|
||||
ret = av_timecode_init(&mxf->tc, rate, 0, 0, s);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
sc->video_bit_rate = st->codec->bit_rate ? st->codec->bit_rate : st->codec->rc_max_rate;
|
||||
if (s->oformat == &ff_mxf_d10_muxer) {
|
||||
if (st->codec->bit_rate == 50000000) {
|
||||
if (sc->video_bit_rate == 50000000) {
|
||||
if (mxf->time_base.den == 25) sc->index = 3;
|
||||
else sc->index = 5;
|
||||
} else if (st->codec->bit_rate == 40000000) {
|
||||
} else if (sc->video_bit_rate == 40000000) {
|
||||
if (mxf->time_base.den == 25) sc->index = 7;
|
||||
else sc->index = 9;
|
||||
} else if (st->codec->bit_rate == 30000000) {
|
||||
} else if (sc->video_bit_rate == 30000000) {
|
||||
if (mxf->time_base.den == 25) sc->index = 11;
|
||||
else sc->index = 13;
|
||||
} else {
|
||||
@@ -1721,7 +1724,7 @@ static int mxf_write_header(AVFormatContext *s)
|
||||
}
|
||||
|
||||
mxf->edit_unit_byte_count = KAG_SIZE; // system element
|
||||
mxf->edit_unit_byte_count += 16 + 4 + (uint64_t)st->codec->bit_rate *
|
||||
mxf->edit_unit_byte_count += 16 + 4 + (uint64_t)sc->video_bit_rate *
|
||||
mxf->time_base.num / (8*mxf->time_base.den);
|
||||
mxf->edit_unit_byte_count += klv_fill_size(mxf->edit_unit_byte_count);
|
||||
mxf->edit_unit_byte_count += 16 + 4 + 4 + spf->samples_per_frame[0]*8*4;
|
||||
@@ -1855,7 +1858,8 @@ static void mxf_write_d10_video_packet(AVFormatContext *s, AVStream *st, AVPacke
|
||||
{
|
||||
MXFContext *mxf = s->priv_data;
|
||||
AVIOContext *pb = s->pb;
|
||||
int packet_size = (uint64_t)st->codec->bit_rate*mxf->time_base.num /
|
||||
MXFStreamContext *sc = st->priv_data;
|
||||
int packet_size = (uint64_t)sc->video_bit_rate*mxf->time_base.num /
|
||||
(8*mxf->time_base.den); // frame size
|
||||
int pad;
|
||||
|
||||
|
||||
@@ -37,12 +37,14 @@ static int srt_probe(AVProbeData *p)
|
||||
if (AV_RB24(ptr) == 0xEFBBBF)
|
||||
ptr += 3; /* skip UTF-8 BOM */
|
||||
|
||||
while (*ptr == '\r' || *ptr == '\n')
|
||||
ptr++;
|
||||
for (i=0; i<2; i++) {
|
||||
if ((num == i || num + 1 == i)
|
||||
&& sscanf(ptr, "%*d:%*2d:%*2d%*1[,.]%*3d --> %*d:%*2d:%*2d%*1[,.]%3d", &v) == 1)
|
||||
return AVPROBE_SCORE_MAX;
|
||||
num = atoi(ptr);
|
||||
ptr += strcspn(ptr, "\n") + 1;
|
||||
ptr += ff_subtitles_next_line(ptr);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -63,10 +65,11 @@ static int64_t get_pts(const char **buf, int *duration,
|
||||
int64_t start = (hh1*3600LL + mm1*60LL + ss1) * 1000LL + ms1;
|
||||
int64_t end = (hh2*3600LL + mm2*60LL + ss2) * 1000LL + ms2;
|
||||
*duration = end - start;
|
||||
*buf += strcspn(*buf, "\n") + 1;
|
||||
*buf += ff_subtitles_next_line(*buf);
|
||||
return start;
|
||||
}
|
||||
*buf += strcspn(*buf, "\n") + 1;
|
||||
*buf += ff_subtitles_next_line(*buf);
|
||||
|
||||
}
|
||||
return AV_NOPTS_VALUE;
|
||||
}
|
||||
|
||||
+16
-3
@@ -108,7 +108,8 @@ int ff_subtitles_queue_seek(FFDemuxSubtitlesQueue *q, AVFormatContext *s, int st
|
||||
for (i = 0; i < q->nb_subs; i++) {
|
||||
int64_t pts = q->subs[i].pts;
|
||||
uint64_t ts_diff = FFABS(pts - ts);
|
||||
if (pts >= min_ts && pts <= max_ts && ts_diff < min_ts_diff) {
|
||||
if ((stream_index == -1 || q->subs[i].stream_index == stream_index) &&
|
||||
pts >= min_ts && pts <= max_ts && ts_diff < min_ts_diff) {
|
||||
min_ts_diff = ts_diff;
|
||||
idx = i;
|
||||
}
|
||||
@@ -118,13 +119,25 @@ int ff_subtitles_queue_seek(FFDemuxSubtitlesQueue *q, AVFormatContext *s, int st
|
||||
/* look back in the latest subtitles for overlapping subtitles */
|
||||
ts_selected = q->subs[idx].pts;
|
||||
for (i = idx - 1; i >= 0; i--) {
|
||||
if (q->subs[i].duration <= 0)
|
||||
int64_t pts = q->subs[i].pts;
|
||||
if (q->subs[i].duration <= 0 ||
|
||||
(stream_index != -1 && q->subs[i].stream_index != stream_index))
|
||||
continue;
|
||||
if (q->subs[i].pts > ts_selected - q->subs[i].duration)
|
||||
if (pts >= min_ts && pts > ts_selected - q->subs[i].duration)
|
||||
idx = i;
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
/* If the queue is used to store multiple subtitles streams (like with
|
||||
* VobSub) and the stream index is not specified, we need to make sure
|
||||
* to focus on the smallest file position offset for a same timestamp;
|
||||
* queue is ordered by pts and then filepos, so we can take the first
|
||||
* entry for a given timestamp. */
|
||||
if (stream_index == -1)
|
||||
while (idx > 0 && q->subs[idx - 1].pts == q->subs[idx].pts)
|
||||
idx--;
|
||||
|
||||
q->current_sub_idx = idx;
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -96,4 +96,17 @@ const char *ff_smil_get_attr_ptr(const char *s, const char *attr);
|
||||
*/
|
||||
void ff_subtitles_read_chunk(AVIOContext *pb, AVBPrint *buf);
|
||||
|
||||
/**
|
||||
* Get the number of characters to increment to jump to the next line, or to
|
||||
* the end of the string.
|
||||
*/
|
||||
static av_always_inline int ff_subtitles_next_line(const char *ptr)
|
||||
{
|
||||
int n = strcspn(ptr, "\n");
|
||||
ptr += n;
|
||||
if (*ptr == '\n')
|
||||
n++;
|
||||
return n;
|
||||
}
|
||||
|
||||
#endif /* AVFORMAT_SUBTITLES_H */
|
||||
|
||||
@@ -629,7 +629,7 @@ static int w64_read_header(AVFormatContext *s)
|
||||
uint32_t count, chunk_size, i;
|
||||
|
||||
start = avio_tell(pb);
|
||||
end = start + size;
|
||||
end = start + FFALIGN(size, INT64_C(8)) - 24;
|
||||
count = avio_rl32(pb);
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
@@ -655,7 +655,7 @@ static int w64_read_header(AVFormatContext *s)
|
||||
avio_skip(pb, end - avio_tell(pb));
|
||||
} else {
|
||||
av_log(s, AV_LOG_DEBUG, "unknown guid: "FF_PRI_GUID"\n", FF_ARG_GUID(guid));
|
||||
avio_skip(pb, size - 24);
|
||||
avio_skip(pb, FFALIGN(size, INT64_C(8)) - 24);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user