Compare commits
131 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
4bc7c1ba8e | ||
![]() |
0efb4ff86c | ||
![]() |
f0bb0aaaa7 | ||
![]() |
eb3330b050 | ||
![]() |
e31e66948d | ||
![]() |
835bc39b26 | ||
![]() |
bb81b2b2e0 | ||
![]() |
58287d3b10 | ||
![]() |
2a7bdbf67e | ||
![]() |
653cdf42ee | ||
![]() |
829e43017f | ||
![]() |
8d14e1d64e | ||
![]() |
5da68aff96 | ||
![]() |
55aedd679a | ||
![]() |
af26185bdc | ||
![]() |
af1fb1d467 | ||
![]() |
a9fc88ea93 | ||
![]() |
23e4284160 | ||
![]() |
42c7ed49a9 | ||
![]() |
494f2d4f9e | ||
![]() |
9597807ab1 | ||
![]() |
99fe4c577f | ||
![]() |
98e1f0a2db | ||
![]() |
3ee5458aa8 | ||
![]() |
99f953b3fe | ||
![]() |
9b9aee27f4 | ||
![]() |
7e350b7ddd | ||
![]() |
fc4d11ec9b | ||
![]() |
f06e39fe6b | ||
![]() |
fd2ba1807e | ||
![]() |
3ac156b707 | ||
![]() |
09ace619d6 | ||
![]() |
145de32896 | ||
![]() |
812955a12b | ||
![]() |
a63e83cd4b | ||
![]() |
c10f3fed25 | ||
![]() |
04d2f9ace3 | ||
![]() |
10f384e4f5 | ||
![]() |
78aa2ed620 | ||
![]() |
ad1223d6bc | ||
![]() |
a89868d714 | ||
![]() |
607863acae | ||
![]() |
2ff935a060 | ||
![]() |
2e4c649b3e | ||
![]() |
60701469ab | ||
![]() |
4d60ab62e0 | ||
![]() |
8bd27a167b | ||
![]() |
17e7edf75b | ||
![]() |
a6a8f66608 | ||
![]() |
b62704891d | ||
![]() |
0c8c6b4419 | ||
![]() |
97b6916f93 | ||
![]() |
ce1dacb435 | ||
![]() |
78dc022f6f | ||
![]() |
5379c5184b | ||
![]() |
4d90550cf9 | ||
![]() |
bacf5db196 | ||
![]() |
5358f1b507 | ||
![]() |
de75bc01cd | ||
![]() |
0b0f1cd44e | ||
![]() |
00516b5491 | ||
![]() |
3706c22992 | ||
![]() |
eac1c3f384 | ||
![]() |
163196562f | ||
![]() |
2e12af4587 | ||
![]() |
20c8f17629 | ||
![]() |
c8c93795e4 | ||
![]() |
38bd229af9 | ||
![]() |
fe8bc7d1ee | ||
![]() |
9f7a8b8f8f | ||
![]() |
9272aa4698 | ||
![]() |
aeca97a7b5 | ||
![]() |
b4c479a82a | ||
![]() |
9f883e75e6 | ||
![]() |
e47543eda5 | ||
![]() |
153deed18b | ||
![]() |
9eba02d5dd | ||
![]() |
557df77eab | ||
![]() |
f8a72f041c | ||
![]() |
9e505065b5 | ||
![]() |
eba112b4e3 | ||
![]() |
d411f07751 | ||
![]() |
8484351749 | ||
![]() |
01a58b439d | ||
![]() |
47bb4d888e | ||
![]() |
057f655dc6 | ||
![]() |
3bd0cd2677 | ||
![]() |
a4acb5b900 | ||
![]() |
c42fd4c6ee | ||
![]() |
3eee21406a | ||
![]() |
852ee0e0ad | ||
![]() |
ed2c15eadc | ||
![]() |
4ad0330b3d | ||
![]() |
9fde820d8e | ||
![]() |
b5e2ef771d | ||
![]() |
63e370b2cf | ||
![]() |
af225c41d4 | ||
![]() |
bf31271478 | ||
![]() |
8715ca0b82 | ||
![]() |
4d073ddac9 | ||
![]() |
007f3f4165 | ||
![]() |
6d2e3efd7c | ||
![]() |
fbbd6317e2 | ||
![]() |
87908de715 | ||
![]() |
de5e003369 | ||
![]() |
5c6aea5c31 | ||
![]() |
dfe0ba46bf | ||
![]() |
6bfa823b70 | ||
![]() |
701543a081 | ||
![]() |
580418bd55 | ||
![]() |
777bc81a91 | ||
![]() |
1e9e311e21 | ||
![]() |
0eb465f981 | ||
![]() |
b01e4d80c6 | ||
![]() |
68c9904669 | ||
![]() |
790606cfe9 | ||
![]() |
7b9bcd993c | ||
![]() |
aade60ab16 | ||
![]() |
3d91117df0 | ||
![]() |
9486e98712 | ||
![]() |
f3c7e604fa | ||
![]() |
4cb3efc206 | ||
![]() |
1e9d234c0c | ||
![]() |
8dc4b2c92e | ||
![]() |
251b4655be | ||
![]() |
1a65ce923a | ||
![]() |
b438451b7e | ||
![]() |
f1f8c0e558 | ||
![]() |
c93874c3a8 | ||
![]() |
e27fab0e6e | ||
![]() |
f743c4ece8 |
@@ -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.1.6
|
||||
PROJECT_NUMBER = 1.1.7
|
||||
|
||||
# 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
|
||||
|
@@ -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
|
||||
|
||||
|
@@ -140,6 +140,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
|
||||
|
@@ -328,6 +328,14 @@ static AVLFG random_state;
|
||||
|
||||
static FILE *logfile = NULL;
|
||||
|
||||
static void htmlstrip(char *s) {
|
||||
while (s && *s) {
|
||||
s += strspn(s, "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ,. ");
|
||||
if (*s)
|
||||
*s++ = '?';
|
||||
}
|
||||
}
|
||||
|
||||
static int64_t ffm_read_write_index(int fd)
|
||||
{
|
||||
uint8_t buf[8];
|
||||
@@ -1887,6 +1895,7 @@ static int http_parse_request(HTTPContext *c)
|
||||
send_error:
|
||||
c->http_error = 404;
|
||||
q = c->buffer;
|
||||
htmlstrip(msg);
|
||||
snprintf(q, c->buffer_size,
|
||||
"HTTP/1.0 404 Not Found\r\n"
|
||||
"Content-type: text/html\r\n"
|
||||
|
@@ -321,6 +321,9 @@ static int decode_element(AVCodecContext *avctx, void *data, int ch_index,
|
||||
rice_history_mult[ch] = get_bits(&alac->gb, 3);
|
||||
lpc_order[ch] = get_bits(&alac->gb, 5);
|
||||
|
||||
if (lpc_order[ch] >= alac->max_samples_per_frame)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
/* read the predictor table */
|
||||
for (i = lpc_order[ch] - 1; i >= 0; i--)
|
||||
lpc_coefs[ch][i] = get_sbits(&alac->gb, 16);
|
||||
@@ -462,9 +465,8 @@ static int alac_decode_frame(AVCodecContext *avctx, void *data,
|
||||
}
|
||||
|
||||
channels = (element == TYPE_CPE) ? 2 : 1;
|
||||
if ( ch + channels > alac->channels
|
||||
|| ff_alac_channel_layout_offsets[alac->channels - 1][ch] + channels > alac->channels
|
||||
) {
|
||||
if (ch + channels > alac->channels ||
|
||||
ff_alac_channel_layout_offsets[alac->channels - 1][ch] + channels > alac->channels) {
|
||||
av_log(avctx, AV_LOG_ERROR, "invalid element channel count\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
@@ -546,7 +548,8 @@ static int alac_set_info(ALACContext *alac)
|
||||
bytestream2_skipu(&gb, 12); // size:4, alac:4, version:4
|
||||
|
||||
alac->max_samples_per_frame = bytestream2_get_be32u(&gb);
|
||||
if (!alac->max_samples_per_frame || alac->max_samples_per_frame > INT_MAX) {
|
||||
if (!alac->max_samples_per_frame ||
|
||||
alac->max_samples_per_frame > INT_MAX / sizeof(int32_t)) {
|
||||
av_log(alac->avctx, AV_LOG_ERROR, "max samples per frame invalid: %u\n",
|
||||
alac->max_samples_per_frame);
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
@@ -282,6 +282,11 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
||||
const int scale = avctx->codec_id == AV_CODEC_ID_ASV1 ? 1 : 2;
|
||||
int i;
|
||||
|
||||
if (avctx->extradata_size < 1) {
|
||||
av_log(avctx, AV_LOG_ERROR, "No extradata provided\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
ff_asv_common_init(avctx);
|
||||
init_vlcs(a);
|
||||
ff_init_scantable(a->dsp.idct_permutation, &a->scantable, ff_asv_scantab);
|
||||
|
@@ -944,6 +944,11 @@ static int decode_pic(AVSContext *h)
|
||||
int ret;
|
||||
enum cavs_mb mb_type;
|
||||
|
||||
if (!h->top_qp) {
|
||||
av_log(h->avctx, AV_LOG_ERROR, "No sequence header decoded yet\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
skip_bits(&h->gb, 16);//bbv_dwlay
|
||||
if (h->stc == PIC_PB_START_CODE) {
|
||||
h->cur.f->pict_type = get_bits(&h->gb, 2) + AV_PICTURE_TYPE_I;
|
||||
|
@@ -738,10 +738,10 @@ static int dca_parse_frame_header(DCAContext *s)
|
||||
s->lfe = get_bits(&s->gb, 2);
|
||||
s->predictor_history = get_bits(&s->gb, 1);
|
||||
|
||||
if (s->lfe == 3) {
|
||||
if (s->lfe > 2) {
|
||||
s->lfe = 0;
|
||||
av_log_ask_for_sample(s->avctx, "LFE is 3\n");
|
||||
return AVERROR_PATCHWELCOME;
|
||||
av_log(s->avctx, AV_LOG_ERROR, "Invalid LFE value: %d\n", s->lfe);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
/* TODO: check CRC */
|
||||
|
@@ -114,8 +114,8 @@ static void cmv_decode_inter(CmvContext * s, const uint8_t *buf, const uint8_t *
|
||||
int yoffset = ((buf[i] >> 4)) - 7;
|
||||
if (s->last_frame.data[0])
|
||||
cmv_motcomp(s->frame.data[0], s->frame.linesize[0],
|
||||
s->last_frame.data[0], s->last_frame.linesize[0],
|
||||
x*4, y*4, xoffset, yoffset, s->avctx->width, s->avctx->height);
|
||||
s->last_frame.data[0], s->last_frame.linesize[0],
|
||||
x*4, y*4, xoffset, yoffset, s->avctx->width, s->avctx->height);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
@@ -275,7 +275,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;
|
||||
}
|
||||
|
@@ -145,6 +145,11 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
enum AVPixelFormat pix_fmt;
|
||||
int ret;
|
||||
|
||||
if (buf_size < 4) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Packet is too short\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
header = AV_RL32(buf);
|
||||
version = header & 0xff;
|
||||
header_size = (header & (1<<30))? 8 : 4; /* bit 30 means pad to 8 bytes */
|
||||
@@ -216,7 +221,7 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
return ret;
|
||||
}
|
||||
|
||||
switch(version) {
|
||||
switch (version) {
|
||||
case 0:
|
||||
default:
|
||||
/* Fraps v0 is a reordered YUV420 */
|
||||
@@ -226,13 +231,13 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
buf32=(const uint32_t*)buf;
|
||||
for(y=0; y<avctx->height/2; y++){
|
||||
luma1=(uint32_t*)&f->data[0][ y*2*f->linesize[0] ];
|
||||
luma2=(uint32_t*)&f->data[0][ (y*2+1)*f->linesize[0] ];
|
||||
cr=(uint32_t*)&f->data[1][ y*f->linesize[1] ];
|
||||
cb=(uint32_t*)&f->data[2][ y*f->linesize[2] ];
|
||||
for(x=0; x<avctx->width; x+=8){
|
||||
buf32 = (const uint32_t*)buf;
|
||||
for (y = 0; y < avctx->height / 2; y++) {
|
||||
luma1 = (uint32_t*)&f->data[0][ y * 2 * f->linesize[0] ];
|
||||
luma2 = (uint32_t*)&f->data[0][ (y * 2 + 1) * f->linesize[0] ];
|
||||
cr = (uint32_t*)&f->data[1][ y * f->linesize[1] ];
|
||||
cb = (uint32_t*)&f->data[2][ y * f->linesize[2] ];
|
||||
for(x=0; x<avctx->width; x+=8) {
|
||||
*luma1++ = *buf32++;
|
||||
*luma1++ = *buf32++;
|
||||
*luma2++ = *buf32++;
|
||||
@@ -245,10 +250,10 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
|
||||
case 1:
|
||||
/* Fraps v1 is an upside-down BGR24 */
|
||||
for(y=0; y<avctx->height; y++)
|
||||
memcpy(&f->data[0][ (avctx->height - y -1) * f->linesize[0]],
|
||||
&buf[y*avctx->width*3],
|
||||
3*avctx->width);
|
||||
for (y = 0; y < avctx->height; y++)
|
||||
memcpy(&f->data[0][ (avctx->height - y - 1) * f->linesize[0]],
|
||||
&buf[y * avctx->width * 3],
|
||||
3 * avctx->width);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
|
@@ -597,17 +597,6 @@ retry:
|
||||
/* FIXME: By the way H263 decoder is evolving it should have */
|
||||
/* an H263EncContext */
|
||||
|
||||
if ((!avctx->coded_width || !avctx->coded_height) && 0) {
|
||||
ParseContext pc= s->parse_context; //FIXME move these demuxng hack to avformat
|
||||
|
||||
s->parse_context.buffer=0;
|
||||
ff_MPV_common_end(s);
|
||||
s->parse_context= pc;
|
||||
avcodec_set_dimensions(avctx, s->width, s->height);
|
||||
|
||||
goto retry;
|
||||
}
|
||||
|
||||
if (s->width != avctx->coded_width ||
|
||||
s->height != avctx->coded_height ||
|
||||
s->context_reinit) {
|
||||
|
@@ -969,6 +969,11 @@ int ff_ivi_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
|
||||
return AVERROR_PATCHWELCOME;
|
||||
}
|
||||
|
||||
if (!ctx->planes[0].bands) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Color planes not initialized yet\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
ctx->switch_buffers(ctx);
|
||||
|
||||
//{ START_TIMER;
|
||||
|
@@ -229,8 +229,8 @@ static av_cold int mace_decode_init(AVCodecContext * avctx)
|
||||
{
|
||||
MACEContext *ctx = avctx->priv_data;
|
||||
|
||||
if (avctx->channels > 2 || avctx->channels <= 0)
|
||||
return -1;
|
||||
if (avctx->channels > 2 || avctx->channels < 1)
|
||||
return AVERROR(EINVAL);
|
||||
avctx->sample_fmt = AV_SAMPLE_FMT_S16P;
|
||||
|
||||
avcodec_get_frame_defaults(&ctx->frame);
|
||||
|
@@ -254,7 +254,8 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
|
||||
return -1;
|
||||
if (s->interlaced && (s->bottom_field == !s->interlace_polarity)) {
|
||||
if (nb_components != s->nb_components) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "nb_components changing in interlaced picture\n");
|
||||
av_log(s->avctx, AV_LOG_ERROR,
|
||||
"nb_components changing in interlaced picture\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
}
|
||||
@@ -770,6 +771,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,
|
||||
|
@@ -160,7 +160,7 @@ static inline int mpeg4_is_resync(MpegEncContext *s){
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mpeg4_decode_sprite_trajectory(MpegEncContext * s, GetBitContext *gb)
|
||||
static int mpeg4_decode_sprite_trajectory(MpegEncContext *s, GetBitContext *gb)
|
||||
{
|
||||
int i;
|
||||
int a= 2<<s->sprite_warping_accuracy;
|
||||
@@ -176,8 +176,8 @@ static int mpeg4_decode_sprite_trajectory(MpegEncContext * s, GetBitContext *gb)
|
||||
int h= s->height;
|
||||
int min_ab;
|
||||
|
||||
if(w<=0 || h<=0)
|
||||
return -1;
|
||||
if (w <= 0 || h <= 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
for(i=0; i<s->num_sprite_warping_points; i++){
|
||||
int length;
|
||||
@@ -415,8 +415,8 @@ int ff_mpeg4_decode_video_packet_header(MpegEncContext *s)
|
||||
skip_bits(&s->gb, 3); /* intra dc vlc threshold */
|
||||
//FIXME don't just ignore everything
|
||||
if(s->pict_type == AV_PICTURE_TYPE_S && s->vol_sprite_usage==GMC_SPRITE){
|
||||
if(mpeg4_decode_sprite_trajectory(s, &s->gb) < 0)
|
||||
return -1;
|
||||
if (mpeg4_decode_sprite_trajectory(s, &s->gb) < 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
av_log(s->avctx, AV_LOG_ERROR, "untested\n");
|
||||
}
|
||||
|
||||
@@ -2081,8 +2081,8 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb){
|
||||
}
|
||||
|
||||
if(s->pict_type == AV_PICTURE_TYPE_S && (s->vol_sprite_usage==STATIC_SPRITE || s->vol_sprite_usage==GMC_SPRITE)){
|
||||
if(mpeg4_decode_sprite_trajectory(s, gb) < 0)
|
||||
return -1;
|
||||
if (mpeg4_decode_sprite_trajectory(s, gb) < 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
if(s->sprite_brightness_change) av_log(s->avctx, AV_LOG_ERROR, "sprite_brightness_change not supported\n");
|
||||
if(s->vol_sprite_usage==STATIC_SPRITE) av_log(s->avctx, AV_LOG_ERROR, "static sprite not supported\n");
|
||||
}
|
||||
|
@@ -1965,7 +1965,8 @@ static int decode_frame_mp3on4(AVCodecContext *avctx, void *data,
|
||||
|
||||
avpriv_mpegaudio_decode_header((MPADecodeHeader *)m, header);
|
||||
|
||||
if (ch + m->nb_channels > avctx->channels || s->coff[fr] + m->nb_channels > avctx->channels) {
|
||||
if (ch + m->nb_channels > avctx->channels ||
|
||||
s->coff[fr] + m->nb_channels > avctx->channels) {
|
||||
av_log(avctx, AV_LOG_ERROR, "frame channel count exceeds codec "
|
||||
"channel count\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
@@ -888,7 +888,9 @@ av_cold int ff_MPV_common_init(MpegEncContext *s)
|
||||
s->flags2 = s->avctx->flags2;
|
||||
|
||||
/* set chroma shifts */
|
||||
avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &s->chroma_x_shift, &s->chroma_y_shift);
|
||||
avcodec_get_chroma_sub_sample(s->avctx->pix_fmt,
|
||||
&s->chroma_x_shift,
|
||||
&s->chroma_y_shift);
|
||||
|
||||
/* convert fourcc to upper case */
|
||||
s->codec_tag = avpriv_toupper4(s->avctx->codec_tag);
|
||||
|
@@ -215,7 +215,8 @@ void mpeg_motion_internal(MpegEncContext *s,
|
||||
{
|
||||
uint8_t *ptr_y, *ptr_cb, *ptr_cr;
|
||||
int dxy, uvdxy, mx, my, src_x, src_y,
|
||||
uvsrc_x, uvsrc_y, v_edge_pos, uvlinesize, linesize;
|
||||
uvsrc_x, uvsrc_y, v_edge_pos;
|
||||
emuedge_linesize_type uvlinesize, linesize;
|
||||
|
||||
#if 0
|
||||
if(s->quarter_sample)
|
||||
|
@@ -157,6 +157,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
|
||||
int keyframe;
|
||||
int size_change = 0;
|
||||
int result;
|
||||
int ret;
|
||||
enum {
|
||||
NUV_UNCOMPRESSED = '0',
|
||||
NUV_RTJPEG = '1',
|
||||
@@ -273,7 +274,9 @@ retry:
|
||||
}
|
||||
case NUV_RTJPEG_IN_LZO:
|
||||
case NUV_RTJPEG:
|
||||
ff_rtjpeg_decode_frame_yuv420(&c->rtj, &c->pic, buf, buf_size);
|
||||
ret = ff_rtjpeg_decode_frame_yuv420(&c->rtj, &c->pic, buf, buf_size);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
break;
|
||||
case NUV_BLACK:
|
||||
memset(c->pic.data[0], 0, c->width * c->height);
|
||||
|
@@ -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,
|
||||
|
@@ -184,7 +184,13 @@ static int pcx_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
|
||||
} else if (nplanes == 1 && bits_per_pixel == 8) {
|
||||
int palstart = avpkt->size - 769;
|
||||
|
||||
for (y=0; y<h; y++, ptr+=stride) {
|
||||
if (avpkt->size < 769) {
|
||||
av_log(avctx, AV_LOG_ERROR, "File is too short\n");
|
||||
ret = avpkt->size;
|
||||
goto end;
|
||||
}
|
||||
|
||||
for (y = 0; y < h; y++, ptr += stride) {
|
||||
pcx_rle_decode(&gb, scanline, bytes_per_scanline, compressed);
|
||||
memcpy(ptr, scanline, w);
|
||||
}
|
||||
@@ -195,7 +201,7 @@ static int pcx_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
|
||||
}
|
||||
if (bytestream2_get_byte(&gb) != 12) {
|
||||
av_log(avctx, AV_LOG_ERROR, "expected palette after image data\n");
|
||||
ret = AVERROR_INVALIDDATA;
|
||||
ret = avpkt->size;
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@@ -237,6 +237,8 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
|
||||
if (bits_per_plane == 8) {
|
||||
picmemset_8bpp(s, val, run, &x, &y);
|
||||
if (y < 0)
|
||||
goto finish;
|
||||
} else {
|
||||
picmemset(s, val, run, &x, &y, &plane, bits_per_plane);
|
||||
}
|
||||
@@ -257,6 +259,7 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
y--;
|
||||
}
|
||||
}
|
||||
finish:
|
||||
|
||||
*got_frame = 1;
|
||||
*(AVFrame*)data = s->frame;
|
||||
|
@@ -380,6 +380,10 @@ static int png_decode_idat(PNGDecContext *s, int length)
|
||||
s->zstream.avail_out = s->crow_size;
|
||||
s->zstream.next_out = s->crow_buf;
|
||||
}
|
||||
if (ret == Z_STREAM_END && s->zstream.avail_in > 0) {
|
||||
av_log(NULL, AV_LOG_WARNING, "%d undecompressed bytes left in buffer\n", s->zstream.avail_in);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@@ -193,7 +193,7 @@ static void qpeg_decode_inter(QpegContext *qctx, uint8_t *dst,
|
||||
filled = 0;
|
||||
dst -= stride;
|
||||
height--;
|
||||
if(height < 0)
|
||||
if (height < 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -209,7 +209,7 @@ static void qpeg_decode_inter(QpegContext *qctx, uint8_t *dst,
|
||||
filled = 0;
|
||||
dst -= stride;
|
||||
height--;
|
||||
if(height < 0)
|
||||
if (height < 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@@ -203,7 +203,7 @@ static void rpza_decode_stream(RpzaContext *s)
|
||||
|
||||
/* Fill block with 16 colors */
|
||||
case 0x00:
|
||||
if (s->size - stream_ptr < 16)
|
||||
if (s->size - stream_ptr < 30)
|
||||
return;
|
||||
ADVANCE_BLOCK();
|
||||
block_ptr = row_ptr + pixel_ptr;
|
||||
|
@@ -458,12 +458,15 @@ static av_cold int rv10_decode_init(AVCodecContext *avctx)
|
||||
RVDecContext *rv = avctx->priv_data;
|
||||
MpegEncContext *s = &rv->m;
|
||||
static int done=0;
|
||||
int major_ver, minor_ver, micro_ver;
|
||||
int major_ver, minor_ver, micro_ver, ret;
|
||||
|
||||
if (avctx->extradata_size < 8) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Extradata is too small.\n");
|
||||
return -1;
|
||||
}
|
||||
if ((ret = av_image_check_size(avctx->coded_width,
|
||||
avctx->coded_height, 0, avctx)) < 0)
|
||||
return ret;
|
||||
|
||||
ff_MPV_decode_defaults(s);
|
||||
|
||||
|
@@ -249,9 +249,11 @@ static void rv30_loop_filter(RV34DecContext *r, int row)
|
||||
static av_cold int rv30_decode_init(AVCodecContext *avctx)
|
||||
{
|
||||
RV34DecContext *r = avctx->priv_data;
|
||||
int ret;
|
||||
|
||||
r->rv30 = 1;
|
||||
ff_rv34_decode_init(avctx);
|
||||
if ((ret = ff_rv34_decode_init(avctx)) < 0)
|
||||
return ret;
|
||||
if(avctx->extradata_size < 2){
|
||||
av_log(avctx, AV_LOG_ERROR, "Extradata is too small.\n");
|
||||
return -1;
|
||||
|
@@ -548,9 +548,11 @@ static void rv40_loop_filter(RV34DecContext *r, int row)
|
||||
static av_cold int rv40_decode_init(AVCodecContext *avctx)
|
||||
{
|
||||
RV34DecContext *r = avctx->priv_data;
|
||||
int ret;
|
||||
|
||||
r->rv30 = 0;
|
||||
ff_rv34_decode_init(avctx);
|
||||
if ((ret = ff_rv34_decode_init(avctx)) < 0)
|
||||
return ret;
|
||||
if(!aic_top_vlc.bits)
|
||||
rv40_init_tables();
|
||||
r->parse_slice_header = rv40_parse_slice_header;
|
||||
|
@@ -213,34 +213,38 @@ static int decode_wave_header(AVCodecContext *avctx, const uint8_t *header,
|
||||
{
|
||||
int len, bps;
|
||||
short wave_format;
|
||||
const uint8_t *end= header + header_size;
|
||||
GetByteContext gb;
|
||||
|
||||
if (bytestream_get_le32(&header) != MKTAG('R', 'I', 'F', 'F')) {
|
||||
bytestream2_init(&gb, header, header_size);
|
||||
|
||||
if (bytestream2_get_le32(&gb) != MKTAG('R', 'I', 'F', 'F')) {
|
||||
av_log(avctx, AV_LOG_ERROR, "missing RIFF tag\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
header += 4; /* chunk size */
|
||||
bytestream2_skip(&gb, 4); /* chunk size */
|
||||
|
||||
if (bytestream_get_le32(&header) != MKTAG('W', 'A', 'V', 'E')) {
|
||||
if (bytestream2_get_le32(&gb) != MKTAG('W', 'A', 'V', 'E')) {
|
||||
av_log(avctx, AV_LOG_ERROR, "missing WAVE tag\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
while (bytestream_get_le32(&header) != MKTAG('f', 'm', 't', ' ')) {
|
||||
len = bytestream_get_le32(&header);
|
||||
if (len<0 || end - header - 8 < len)
|
||||
while (bytestream2_get_le32(&gb) != MKTAG('f', 'm', 't', ' ')) {
|
||||
len = bytestream2_get_le32(&gb);
|
||||
bytestream2_skip(&gb, len);
|
||||
if (len < 0 || bytestream2_get_bytes_left(&gb) < 16) {
|
||||
av_log(avctx, AV_LOG_ERROR, "no fmt chunk found\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
header += len;
|
||||
}
|
||||
}
|
||||
len = bytestream_get_le32(&header);
|
||||
len = bytestream2_get_le32(&gb);
|
||||
|
||||
if (len < 16) {
|
||||
av_log(avctx, AV_LOG_ERROR, "fmt chunk was too short\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
wave_format = bytestream_get_le16(&header);
|
||||
wave_format = bytestream2_get_le16(&gb);
|
||||
|
||||
switch (wave_format) {
|
||||
case WAVE_FORMAT_PCM:
|
||||
@@ -250,11 +254,11 @@ static int decode_wave_header(AVCodecContext *avctx, const uint8_t *header,
|
||||
return AVERROR(ENOSYS);
|
||||
}
|
||||
|
||||
header += 2; // skip channels (already got from shorten header)
|
||||
avctx->sample_rate = bytestream_get_le32(&header);
|
||||
header += 4; // skip bit rate (represents original uncompressed bit rate)
|
||||
header += 2; // skip block align (not needed)
|
||||
bps = bytestream_get_le16(&header);
|
||||
bytestream2_skip(&gb, 2); // skip channels (already got from shorten header)
|
||||
avctx->sample_rate = bytestream2_get_le32(&gb);
|
||||
bytestream2_skip(&gb, 4); // skip bit rate (represents original uncompressed bit rate)
|
||||
bytestream2_skip(&gb, 2); // skip block align (not needed)
|
||||
bps = bytestream2_get_le16(&gb);
|
||||
avctx->bits_per_coded_sample = bps;
|
||||
|
||||
if (bps != 16 && bps != 8) {
|
||||
|
@@ -268,10 +268,12 @@ static int smacker_decode_header_tree(SmackVContext *smk, GetBitContext *gb, int
|
||||
if(ctx.last[0] == -1) ctx.last[0] = huff.current++;
|
||||
if(ctx.last[1] == -1) ctx.last[1] = huff.current++;
|
||||
if(ctx.last[2] == -1) ctx.last[2] = huff.current++;
|
||||
if(huff.current > huff.length){
|
||||
if (ctx.last[0] >= huff.length ||
|
||||
ctx.last[1] >= huff.length ||
|
||||
ctx.last[2] >= huff.length) {
|
||||
av_log(smk->avctx, AV_LOG_ERROR, "Huffman codes out of range\n");
|
||||
ctx.last[0] = ctx.last[1] = ctx.last[2] = 1;
|
||||
av_log(smk->avctx, AV_LOG_ERROR, "bigtree damaged\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
err = AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
*recodes = huff.values;
|
||||
|
@@ -638,9 +638,9 @@ static int svq3_decode_mb(SVQ3Context *svq3, unsigned int mb_type)
|
||||
dir = i_mb_type_info[mb_type - 8].pred_mode;
|
||||
dir = (dir >> 1) ^ 3 * (dir & 1) ^ 1;
|
||||
|
||||
if ((h->intra16x16_pred_mode = ff_h264_check_intra_pred_mode(h, dir, 0)) == -1) {
|
||||
av_log(h->s.avctx, AV_LOG_ERROR, "check_intra_pred_mode = -1\n");
|
||||
return -1;
|
||||
if ((h->intra16x16_pred_mode = ff_h264_check_intra_pred_mode(h, dir, 0)) < 0) {
|
||||
av_log(h->s.avctx, AV_LOG_ERROR, "ff_h264_check_intra_pred_mode < 0\n");
|
||||
return h->intra16x16_pred_mode;
|
||||
}
|
||||
|
||||
cbp = i_mb_type_info[mb_type - 8].cbp;
|
||||
@@ -962,7 +962,8 @@ static av_cold int svq3_decode_init(AVCodecContext *avctx)
|
||||
int offset = get_bits_count(&gb) + 7 >> 3;
|
||||
uint8_t *buf;
|
||||
|
||||
if (watermark_height <= 0 || (uint64_t)watermark_width*4 > UINT_MAX/watermark_height)
|
||||
if (watermark_height <= 0 ||
|
||||
(uint64_t)watermark_width * 4 > UINT_MAX / watermark_height)
|
||||
return -1;
|
||||
|
||||
buf = av_malloc(buf_len);
|
||||
|
@@ -922,14 +922,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;
|
||||
|
@@ -1142,12 +1142,12 @@ static av_cold int twin_decode_init(AVCodecContext *avctx)
|
||||
AV_CH_LAYOUT_STEREO;
|
||||
|
||||
ibps = avctx->bit_rate / (1000 * avctx->channels);
|
||||
|
||||
if (ibps > 255U) {
|
||||
av_log(avctx, AV_LOG_ERROR, "unsupported per channel bitrate %dkbps\n", ibps);
|
||||
if (ibps < 8 || ibps > 48) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Bad bitrate per channel value %d\n", ibps);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
|
||||
switch ((isampf << 8) + ibps) {
|
||||
case (8 <<8) + 8: tctx->mtab = &mode_08_08; break;
|
||||
case (11<<8) + 8: tctx->mtab = &mode_11_08; break;
|
||||
|
@@ -4750,6 +4750,9 @@ static void vc1_decode_skip_blocks(VC1Context *v)
|
||||
{
|
||||
MpegEncContext *s = &v->s;
|
||||
|
||||
if (!v->s.last_picture.f.data[0])
|
||||
return;
|
||||
|
||||
ff_er_add_slice(s, 0, s->start_mb_y, s->mb_width - 1, s->end_mb_y - 1, ER_MB_END);
|
||||
s->first_slice_line = 1;
|
||||
for (s->mb_y = s->start_mb_y; s->mb_y < s->end_mb_y; s->mb_y++) {
|
||||
@@ -5141,8 +5144,19 @@ av_cold int ff_vc1_decode_init_alloc_tables(VC1Context *v)
|
||||
|
||||
if (!v->mv_type_mb_plane || !v->direct_mb_plane || !v->acpred_plane || !v->over_flags_plane ||
|
||||
!v->block || !v->cbp_base || !v->ttblk_base || !v->is_intra_base || !v->luma_mv_base ||
|
||||
!v->mb_type_base)
|
||||
return -1;
|
||||
!v->mb_type_base) {
|
||||
av_freep(&v->mv_type_mb_plane);
|
||||
av_freep(&v->direct_mb_plane);
|
||||
av_freep(&v->acpred_plane);
|
||||
av_freep(&v->over_flags_plane);
|
||||
av_freep(&v->block);
|
||||
av_freep(&v->cbp_base);
|
||||
av_freep(&v->ttblk_base);
|
||||
av_freep(&v->is_intra_base);
|
||||
av_freep(&v->luma_mv_base);
|
||||
av_freep(&v->mb_type_base);
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -5514,8 +5528,12 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
|
||||
}
|
||||
|
||||
if (!s->context_initialized) {
|
||||
if (ff_msmpeg4_decode_init(avctx) < 0 || ff_vc1_decode_init_alloc_tables(v) < 0)
|
||||
if (ff_msmpeg4_decode_init(avctx) < 0)
|
||||
goto err;
|
||||
if (ff_vc1_decode_init_alloc_tables(v) < 0) {
|
||||
ff_MPV_common_end(s);
|
||||
goto err;
|
||||
}
|
||||
|
||||
s->low_delay = !avctx->has_b_frames || v->res_sprite;
|
||||
|
||||
@@ -5648,6 +5666,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
|
||||
goto err;
|
||||
}
|
||||
} else {
|
||||
int header_ret = 0;
|
||||
if (v->fcm == ILACE_FRAME && s->pict_type == AV_PICTURE_TYPE_B)
|
||||
goto err; // This codepath is still incomplete thus it is disabled
|
||||
|
||||
@@ -5697,18 +5716,20 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
|
||||
if (i) {
|
||||
v->pic_header_flag = 0;
|
||||
if (v->field_mode && i == n_slices1 + 2) {
|
||||
if (ff_vc1_parse_frame_header_adv(v, &s->gb) < 0) {
|
||||
if ((header_ret = ff_vc1_parse_frame_header_adv(v, &s->gb)) < 0) {
|
||||
av_log(v->s.avctx, AV_LOG_ERROR, "Field header damaged\n");
|
||||
continue;
|
||||
}
|
||||
} else if (get_bits1(&s->gb)) {
|
||||
v->pic_header_flag = 1;
|
||||
if (ff_vc1_parse_frame_header_adv(v, &s->gb) < 0) {
|
||||
if ((header_ret = ff_vc1_parse_frame_header_adv(v, &s->gb)) < 0) {
|
||||
av_log(v->s.avctx, AV_LOG_ERROR, "Slice header damaged\n");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (header_ret < 0)
|
||||
continue;
|
||||
s->start_mb_y = (i == 0) ? 0 : FFMAX(0, slices[i-1].mby_start % mb_height);
|
||||
if (!v->field_mode || v->second_field)
|
||||
s->end_mb_y = (i == n_slices ) ? mb_height : FFMIN(mb_height, slices[i].mby_start % mb_height);
|
||||
|
@@ -27,6 +27,7 @@
|
||||
#include "avcodec.h"
|
||||
#include "dsputil.h"
|
||||
#include "internal.h"
|
||||
#include "libavutil/avassert.h"
|
||||
#include "libavutil/internal.h"
|
||||
|
||||
typedef struct VCR1Context {
|
||||
@@ -52,9 +53,10 @@ static av_cold int vcr1_decode_init(AVCodecContext *avctx)
|
||||
avctx->pix_fmt = AV_PIX_FMT_YUV410P;
|
||||
|
||||
if (avctx->width % 8 || avctx->height%4) {
|
||||
av_log_ask_for_sample(avctx, "odd dimensions are not supported\n");
|
||||
return AVERROR_PATCHWELCOME;
|
||||
av_log_ask_for_sample(avctx, "odd dimensions (%d x %d) support", avctx->width, avctx->height);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -98,6 +100,7 @@ static int vcr1_decode_frame(AVCodecContext *avctx, void *data,
|
||||
for (i = 0; i < 16; i++) {
|
||||
a->delta[i] = *bytestream++;
|
||||
bytestream++;
|
||||
buf_size--;
|
||||
}
|
||||
|
||||
for (y = 0; y < avctx->height; y++) {
|
||||
@@ -108,8 +111,11 @@ static int vcr1_decode_frame(AVCodecContext *avctx, void *data,
|
||||
uint8_t *cb = &a->picture.data[1][(y >> 2) * a->picture.linesize[1]];
|
||||
uint8_t *cr = &a->picture.data[2][(y >> 2) * a->picture.linesize[2]];
|
||||
|
||||
av_assert0 (buf_size >= 4 + avctx->width);
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
a->offset[i] = *bytestream++;
|
||||
buf_size -= 4;
|
||||
|
||||
offset = a->offset[0] - a->delta[bytestream[2] & 0xF];
|
||||
for (x = 0; x < avctx->width; x += 4) {
|
||||
@@ -123,8 +129,11 @@ static int vcr1_decode_frame(AVCodecContext *avctx, void *data,
|
||||
*cr++ = bytestream[1];
|
||||
|
||||
bytestream += 4;
|
||||
buf_size -= 4;
|
||||
}
|
||||
} else {
|
||||
av_assert0 (buf_size >= avctx->width / 2);
|
||||
|
||||
offset = a->offset[y & 3] - a->delta[bytestream[2] & 0xF];
|
||||
|
||||
for (x = 0; x < avctx->width; x += 8) {
|
||||
@@ -138,6 +147,7 @@ static int vcr1_decode_frame(AVCodecContext *avctx, void *data,
|
||||
luma[7] = offset += a->delta[bytestream[1] >> 4];
|
||||
luma += 8;
|
||||
bytestream += 4;
|
||||
buf_size -= 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -145,7 +155,7 @@ static int vcr1_decode_frame(AVCodecContext *avctx, void *data,
|
||||
*picture = a->picture;
|
||||
*got_frame = 1;
|
||||
|
||||
return buf_size;
|
||||
return bytestream - avpkt->data;
|
||||
}
|
||||
|
||||
AVCodec ff_vcr1_decoder = {
|
||||
|
@@ -29,6 +29,8 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef int emuedge_linesize_type;
|
||||
|
||||
typedef struct VideoDSPContext {
|
||||
/**
|
||||
* Copy a rectangular area of samples to a temporary buffer and replicate
|
||||
|
@@ -27,7 +27,7 @@ void FUNC(ff_emulated_edge_mc)(uint8_t *buf, const uint8_t *src,
|
||||
{
|
||||
int x, y;
|
||||
int start_y, start_x, end_y, end_x;
|
||||
int linesize = linesize_arg;
|
||||
emuedge_linesize_type linesize = linesize_arg;
|
||||
|
||||
if (!w || !h)
|
||||
return;
|
||||
|
@@ -2154,6 +2154,10 @@ static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb)
|
||||
fps.num = get_bits_long(gb, 32);
|
||||
fps.den = get_bits_long(gb, 32);
|
||||
if (fps.num && fps.den) {
|
||||
if (fps.num < 0 || fps.den < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Invalid framerate\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
av_reduce(&avctx->time_base.num, &avctx->time_base.den,
|
||||
fps.den, fps.num, 1<<30);
|
||||
}
|
||||
|
@@ -514,6 +514,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)
|
||||
|
@@ -71,8 +71,8 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
int prev_y = 0, prev_u = 0, prev_v = 0;
|
||||
uint8_t *rbuf;
|
||||
|
||||
if(buf_size<=8) {
|
||||
av_log(avctx, AV_LOG_ERROR, "buf_size %d is too small\n", buf_size);
|
||||
if (buf_size <= 8) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Packet size %d is too small\n", buf_size);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
|
@@ -44,7 +44,7 @@ static av_always_inline void emulated_edge_mc(uint8_t *buf, const uint8_t *src,
|
||||
emu_edge_core_func *core_fn)
|
||||
{
|
||||
int start_y, start_x, end_y, end_x, src_y_add = 0;
|
||||
int linesize = linesize_arg;
|
||||
emuedge_linesize_type linesize = linesize_arg;
|
||||
|
||||
if(!w || !h)
|
||||
return;
|
||||
|
@@ -106,6 +106,7 @@ static int xan_huffman_decode(unsigned char *dest, int dest_len,
|
||||
int ptr_len = src_len - 1 - byte*2;
|
||||
unsigned char val = ival;
|
||||
unsigned char *dest_end = dest + dest_len;
|
||||
unsigned char *dest_start = dest;
|
||||
GetBitContext gb;
|
||||
|
||||
if (ptr_len < 0)
|
||||
@@ -121,13 +122,13 @@ static int xan_huffman_decode(unsigned char *dest, int dest_len,
|
||||
|
||||
if (val < 0x16) {
|
||||
if (dest >= dest_end)
|
||||
return 0;
|
||||
return dest_len;
|
||||
*dest++ = val;
|
||||
val = ival;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return dest - dest_start;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -276,7 +277,7 @@ static int xan_wc3_decode_frame(XanContext *s) {
|
||||
unsigned char flag = 0;
|
||||
int size = 0;
|
||||
int motion_x, motion_y;
|
||||
int x, y;
|
||||
int x, y, ret;
|
||||
|
||||
unsigned char *opcode_buffer = s->buffer1;
|
||||
unsigned char *opcode_buffer_end = s->buffer1 + s->buffer1_size;
|
||||
@@ -285,10 +286,9 @@ static int xan_wc3_decode_frame(XanContext *s) {
|
||||
|
||||
/* pointers to segments inside the compressed chunk */
|
||||
const unsigned char *huffman_segment;
|
||||
const unsigned char *size_segment;
|
||||
const unsigned char *vector_segment;
|
||||
GetByteContext size_segment;
|
||||
GetByteContext vector_segment;
|
||||
const unsigned char *imagedata_segment;
|
||||
const unsigned char *buf_end = s->buf + s->size;
|
||||
int huffman_offset, size_offset, vector_offset, imagedata_offset,
|
||||
imagedata_size;
|
||||
|
||||
@@ -307,13 +307,14 @@ static int xan_wc3_decode_frame(XanContext *s) {
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
huffman_segment = s->buf + huffman_offset;
|
||||
size_segment = s->buf + size_offset;
|
||||
vector_segment = s->buf + vector_offset;
|
||||
bytestream2_init(&size_segment, s->buf + size_offset, s->size - size_offset);
|
||||
bytestream2_init(&vector_segment, s->buf + vector_offset, s->size - vector_offset);
|
||||
imagedata_segment = s->buf + imagedata_offset;
|
||||
|
||||
if (xan_huffman_decode(opcode_buffer, opcode_buffer_size,
|
||||
huffman_segment, s->size - huffman_offset) < 0)
|
||||
if ((ret = xan_huffman_decode(opcode_buffer, opcode_buffer_size,
|
||||
huffman_segment, s->size - huffman_offset)) < 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
opcode_buffer_end = opcode_buffer + ret;
|
||||
|
||||
if (imagedata_segment[0] == 2) {
|
||||
xan_unpack(s->buffer2, s->buffer2_size,
|
||||
@@ -360,31 +361,29 @@ static int xan_wc3_decode_frame(XanContext *s) {
|
||||
|
||||
case 9:
|
||||
case 19:
|
||||
if (buf_end - size_segment < 1) {
|
||||
if (bytestream2_get_bytes_left(&size_segment) < 1) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "size_segment overread\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
size = *size_segment++;
|
||||
size = bytestream2_get_byte(&size_segment);
|
||||
break;
|
||||
|
||||
case 10:
|
||||
case 20:
|
||||
if (buf_end - size_segment < 2) {
|
||||
if (bytestream2_get_bytes_left(&size_segment) < 2) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "size_segment overread\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
size = AV_RB16(&size_segment[0]);
|
||||
size_segment += 2;
|
||||
size = bytestream2_get_be16(&size_segment);
|
||||
break;
|
||||
|
||||
case 11:
|
||||
case 21:
|
||||
if (buf_end - size_segment < 3) {
|
||||
if (bytestream2_get_bytes_left(&size_segment) < 3) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "size_segment overread\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
size = AV_RB24(size_segment);
|
||||
size_segment += 3;
|
||||
size = bytestream2_get_be24(&size_segment);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -405,14 +404,15 @@ static int xan_wc3_decode_frame(XanContext *s) {
|
||||
imagedata_size -= size;
|
||||
}
|
||||
} else {
|
||||
if (vector_segment >= buf_end) {
|
||||
uint8_t vector;
|
||||
if (bytestream2_get_bytes_left(&vector_segment) <= 0) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "vector_segment overread\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
/* run-based motion compensation from last frame */
|
||||
motion_x = sign_extend(*vector_segment >> 4, 4);
|
||||
motion_y = sign_extend(*vector_segment & 0xF, 4);
|
||||
vector_segment++;
|
||||
vector = bytestream2_get_byte(&vector_segment);
|
||||
motion_x = sign_extend(vector >> 4, 4);
|
||||
motion_y = sign_extend(vector & 0xF, 4);
|
||||
|
||||
/* copy a run of pixels from the previous frame */
|
||||
xan_wc3_copy_pixel_run(s, x, y, size, motion_x, motion_y);
|
||||
|
@@ -49,6 +49,10 @@ static av_cold int xan_decode_init(AVCodecContext *avctx)
|
||||
av_log(avctx, AV_LOG_ERROR, "Invalid frame height: %d.\n", avctx->height);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
if (avctx->width & 1) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Invalid frame width: %d.\n", avctx->width);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
s->buffer_size = avctx->width * avctx->height;
|
||||
s->y_buffer = av_malloc(s->buffer_size);
|
||||
|
@@ -508,7 +508,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
|
||||
|
||||
if (c->comp == 0) { //Uncompressed data
|
||||
if (c->decomp_size < len) {
|
||||
av_log(avctx, AV_LOG_ERROR, "decomp buffer too small\n");
|
||||
av_log(avctx, AV_LOG_ERROR, "Buffer too small\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
memcpy(c->decomp_buf, buf, len);
|
||||
|
@@ -882,6 +882,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');
|
||||
st->codec->width = s->width;
|
||||
|
@@ -202,7 +202,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);
|
||||
}
|
||||
|
||||
|
@@ -135,6 +135,8 @@ static int parse_strk(AVFormatContext *s,
|
||||
av_log(s, AV_LOG_ERROR, "current_track too large\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
if (track < 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
if (track + 1 > fourxm->track_count) {
|
||||
fourxm->tracks = av_realloc_f(fourxm->tracks, track + 1, sizeof(AudioTrack));
|
||||
if (!fourxm->tracks)
|
||||
@@ -151,7 +153,7 @@ static int parse_strk(AVFormatContext *s,
|
||||
|
||||
if (fourxm->tracks[track].channels <= 0 ||
|
||||
fourxm->tracks[track].sample_rate <= 0 ||
|
||||
fourxm->tracks[track].bits < 0) {
|
||||
fourxm->tracks[track].bits <= 0) {
|
||||
av_log(s, AV_LOG_ERROR, "audio header invalid\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
@@ -253,7 +253,7 @@ static int ape_read_header(AVFormatContext * s)
|
||||
ape->totalframes);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
if (ape->seektablelength && (ape->seektablelength / sizeof(*ape->seektable)) < ape->totalframes) {
|
||||
if (ape->seektablelength / sizeof(*ape->seektable) < ape->totalframes) {
|
||||
av_log(s, AV_LOG_ERROR,
|
||||
"Number of seek entries is less than number of frames: %zu vs. %"PRIu32"\n",
|
||||
ape->seektablelength / sizeof(*ape->seektable), ape->totalframes);
|
||||
@@ -274,7 +274,9 @@ static int ape_read_header(AVFormatContext * s)
|
||||
ape->seektable = av_malloc(ape->seektablelength);
|
||||
if (!ape->seektable)
|
||||
return AVERROR(ENOMEM);
|
||||
for (i = 0; i < ape->seektablelength / sizeof(uint32_t); i++)
|
||||
for (i = 0;
|
||||
i < ape->seektablelength / sizeof(uint32_t) && !pb->eof_reached;
|
||||
i++)
|
||||
ape->seektable[i] = avio_rl32(pb);
|
||||
}else{
|
||||
av_log(s, AV_LOG_ERROR, "Missing seektable\n");
|
||||
|
@@ -718,7 +718,9 @@ static int asf_read_header(AVFormatContext *s)
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
} else if (!ff_guidcmp(&g, &ff_asf_stream_header)) {
|
||||
asf_read_stream_properties(s, gsize);
|
||||
int ret = asf_read_stream_properties(s, gsize);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
} else if (!ff_guidcmp(&g, &ff_asf_comment_header)) {
|
||||
asf_read_content_desc(s, gsize);
|
||||
} else if (!ff_guidcmp(&g, &ff_asf_language_guid)) {
|
||||
|
@@ -818,8 +818,10 @@ static int avi_read_header(AVFormatContext *s)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int read_gab2_sub(AVStream *st, AVPacket *pkt) {
|
||||
if (pkt->data && !strcmp(pkt->data, "GAB2") && AV_RL16(pkt->data+5) == 2) {
|
||||
static int read_gab2_sub(AVStream *st, AVPacket *pkt)
|
||||
{
|
||||
if (pkt->size >= 7 &&
|
||||
!strcmp(pkt->data, "GAB2") && AV_RL16(pkt->data + 5) == 2) {
|
||||
uint8_t desc[256];
|
||||
int score = AVPROBE_SCORE_MAX / 2, ret;
|
||||
AVIStream *ast = st->priv_data;
|
||||
@@ -1301,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;
|
||||
}
|
||||
|
@@ -134,6 +134,10 @@ static int bfi_read_packet(AVFormatContext * s, AVPacket * pkt)
|
||||
video_offset = avio_rl32(pb);
|
||||
audio_size = video_offset - audio_offset;
|
||||
bfi->video_size = chunk_size - video_offset;
|
||||
if (audio_size < 0 || bfi->video_size < 0) {
|
||||
av_log(s, AV_LOG_ERROR, "Invalid audio/video offsets or chunk size\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
//Tossing an audio packet at the audio decoder.
|
||||
ret = av_get_packet(pb, pkt, audio_size);
|
||||
@@ -142,9 +146,7 @@ static int bfi_read_packet(AVFormatContext * s, AVPacket * pkt)
|
||||
|
||||
pkt->pts = bfi->audio_frame;
|
||||
bfi->audio_frame += ret;
|
||||
}
|
||||
|
||||
else {
|
||||
} else if (bfi->video_size > 0) {
|
||||
|
||||
//Tossing a video packet at the video decoder.
|
||||
ret = av_get_packet(pb, pkt, bfi->video_size);
|
||||
@@ -156,6 +158,9 @@ static int bfi_read_packet(AVFormatContext * s, AVPacket * pkt)
|
||||
|
||||
/* One less frame to read. A cursory decrement. */
|
||||
bfi->nframes--;
|
||||
} else {
|
||||
/* Empty video packet */
|
||||
ret = AVERROR(EAGAIN);
|
||||
}
|
||||
|
||||
bfi->avflag = !bfi->avflag;
|
||||
|
@@ -155,6 +155,8 @@ static int cin_read_frame_header(CinDemuxContext *cin, AVIOContext *pb) {
|
||||
|
||||
if (avio_rl32(pb) != 0xAA55AA55)
|
||||
return AVERROR_INVALIDDATA;
|
||||
if (hdr->video_frame_size < 0 || hdr->audio_frame_size < 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@@ -113,7 +113,7 @@ static const int dv_audio_frequency[3] = {
|
||||
* 3. Audio is always returned as 16bit linear samples: 12bit nonlinear samples
|
||||
* are converted into 16bit linear ones.
|
||||
*/
|
||||
static int dv_extract_audio(uint8_t* frame, uint8_t* ppcm[4],
|
||||
static int dv_extract_audio(uint8_t *frame, uint8_t **ppcm,
|
||||
const DVprofile *sys)
|
||||
{
|
||||
int size, chan, i, j, d, of, smpls, freq, quant, half_ch;
|
||||
@@ -358,7 +358,7 @@ int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket *pkt,
|
||||
uint8_t* buf, int buf_size, int64_t pos)
|
||||
{
|
||||
int size, i;
|
||||
uint8_t *ppcm[4] = {0};
|
||||
uint8_t *ppcm[5] = { 0 };
|
||||
|
||||
if (buf_size < DV_PROFILE_BYTES ||
|
||||
!(c->sys = avpriv_dv_frame_profile(c->sys, buf, buf_size)) ||
|
||||
|
@@ -453,8 +453,9 @@ static int ea_read_header(AVFormatContext *s)
|
||||
}
|
||||
|
||||
if (ea->audio_codec) {
|
||||
if (ea->num_channels <= 0) {
|
||||
av_log(s, AV_LOG_WARNING, "Unsupported number of channels: %d\n", ea->num_channels);
|
||||
if (ea->num_channels <= 0 || ea->num_channels > 2) {
|
||||
av_log(s, AV_LOG_WARNING,
|
||||
"Unsupported number of channels: %d\n", ea->num_channels);
|
||||
ea->audio_codec = 0;
|
||||
return 1;
|
||||
}
|
||||
@@ -545,12 +546,16 @@ static int ea_read_packet(AVFormatContext *s,
|
||||
case AV_CODEC_ID_ADPCM_EA_R1:
|
||||
case AV_CODEC_ID_ADPCM_EA_R2:
|
||||
case AV_CODEC_ID_ADPCM_IMA_EA_EACS:
|
||||
if (pkt->size >= 4)
|
||||
pkt->duration = AV_RL32(pkt->data);
|
||||
break;
|
||||
case AV_CODEC_ID_ADPCM_EA_R3:
|
||||
if (pkt->size >= 4)
|
||||
if (pkt->size < 4) {
|
||||
av_log(s, AV_LOG_ERROR, "Packet is too short\n");
|
||||
av_free_packet(pkt);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
if (ea->audio_codec == AV_CODEC_ID_ADPCM_EA_R3)
|
||||
pkt->duration = AV_RB32(pkt->data);
|
||||
else
|
||||
pkt->duration = AV_RL32(pkt->data);
|
||||
break;
|
||||
case AV_CODEC_ID_ADPCM_IMA_EA_SEAD:
|
||||
pkt->duration = ret * 2 / ea->num_channels;
|
||||
|
@@ -145,6 +145,8 @@ static int roq_read_packet(AVFormatContext *s,
|
||||
break;
|
||||
|
||||
case RoQ_QUAD_CODEBOOK:
|
||||
if (roq->video_stream_index < 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
/* packet needs to contain both this codebook and next VQ chunk */
|
||||
codebook_offset = avio_tell(pb) - RoQ_CHUNK_PREAMBLE_SIZE;
|
||||
codebook_size = chunk_size;
|
||||
@@ -194,6 +196,11 @@ static int roq_read_packet(AVFormatContext *s,
|
||||
st->codec->block_align = st->codec->channels * st->codec->bits_per_coded_sample;
|
||||
}
|
||||
case RoQ_QUAD_VQ:
|
||||
if (chunk_type == RoQ_QUAD_VQ) {
|
||||
if (roq->video_stream_index < 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
/* load up the packet */
|
||||
if (av_new_packet(pkt, chunk_size + RoQ_CHUNK_PREAMBLE_SIZE))
|
||||
return AVERROR(EIO);
|
||||
|
@@ -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,
|
||||
|
@@ -1231,7 +1231,8 @@ static void matroska_convert_tag(AVFormatContext *s, EbmlList *list,
|
||||
int i;
|
||||
|
||||
for (i=0; i < list->nb_elem; i++) {
|
||||
const char *lang= (tags[i].lang && strcmp(tags[i].lang, "und")) ? tags[i].lang : NULL;
|
||||
const char *lang = tags[i].lang && strcmp(tags[i].lang, "und") ?
|
||||
tags[i].lang : NULL;
|
||||
|
||||
if (!tags[i].name) {
|
||||
av_log(s, AV_LOG_WARNING, "Skipping invalid tag with no TagName.\n");
|
||||
@@ -1696,6 +1697,10 @@ static int matroska_read_header(AVFormatContext *s)
|
||||
track->audio.sub_packet_h = avio_rb16(&b);
|
||||
track->audio.frame_size = avio_rb16(&b);
|
||||
track->audio.sub_packet_size = avio_rb16(&b);
|
||||
if (flavor <= 0 || track->audio.coded_framesize <= 0 ||
|
||||
track->audio.sub_packet_h <= 0 || track->audio.frame_size <= 0 ||
|
||||
track->audio.sub_packet_size <= 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
track->audio.buf = av_malloc(track->audio.frame_size * track->audio.sub_packet_h);
|
||||
if (codec_id == AV_CODEC_ID_RA_288) {
|
||||
st->codec->block_align = track->audio.coded_framesize;
|
||||
|
@@ -1383,7 +1383,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 },
|
||||
|
@@ -1821,6 +1821,10 @@ static int mov_read_stts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||
av_log(c->fc, AV_LOG_ERROR, "Invalid SampleDelta in STTS %d\n", sample_duration);
|
||||
sample_duration = 1;
|
||||
}
|
||||
if (sample_count < 0) {
|
||||
av_log(c->fc, AV_LOG_ERROR, "Invalid sample_count=%d\n", sample_count);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
sc->stts_data[i].count= sample_count;
|
||||
sc->stts_data[i].duration= sample_duration;
|
||||
|
||||
@@ -3209,7 +3213,7 @@ static int mov_read_header(AVFormatContext *s)
|
||||
for (i = 0; i < s->nb_streams; i++) {
|
||||
AVStream *st = s->streams[i];
|
||||
MOVStreamContext *sc = st->priv_data;
|
||||
if (st->duration)
|
||||
if (st->duration > 0)
|
||||
st->codec->bit_rate = sc->data_size * 8 * sc->time_scale / st->duration;
|
||||
}
|
||||
}
|
||||
|
@@ -139,6 +139,11 @@ static void mpc8_parse_seektable(AVFormatContext *s, int64_t off)
|
||||
int i, t, seekd;
|
||||
GetBitContext gb;
|
||||
|
||||
if (s->nb_streams == 0) {
|
||||
av_log(s, AV_LOG_ERROR, "No stream added before parsing seek table\n");
|
||||
return;
|
||||
}
|
||||
|
||||
avio_seek(s->pb, off, SEEK_SET);
|
||||
mpc8_get_chunk_header(s->pb, &tag, &size);
|
||||
if(tag != TAG_SEEKTABLE){
|
||||
@@ -146,7 +151,7 @@ static void mpc8_parse_seektable(AVFormatContext *s, int64_t off)
|
||||
return;
|
||||
}
|
||||
if (size > INT_MAX/10 || size<=0) {
|
||||
av_log(s, AV_LOG_ERROR, "Seek table size is invalid\n");
|
||||
av_log(s, AV_LOG_ERROR, "Bad seek table size\n");
|
||||
return;
|
||||
}
|
||||
if(!(buf = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE)))
|
||||
|
@@ -653,6 +653,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;
|
||||
@@ -810,6 +811,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);
|
||||
}
|
||||
|
@@ -95,6 +95,12 @@ static int read_header(AVFormatContext *s)
|
||||
mvi->get_int = (vst->codec->width * vst->codec->height < (1 << 16)) ? avio_rl16 : avio_rl24;
|
||||
|
||||
mvi->audio_frame_size = ((uint64_t)mvi->audio_data_size << MVI_FRAC_BITS) / frames_count;
|
||||
if (mvi->audio_frame_size <= 1 << MVI_FRAC_BITS - 1) {
|
||||
av_log(s, AV_LOG_ERROR, "Invalid audio_data_size (%d) or frames_count (%d)\n",
|
||||
mvi->audio_data_size, frames_count);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
mvi->audio_size_counter = (ast->codec->sample_rate * 830 / mvi->audio_frame_size - 1) * mvi->audio_frame_size;
|
||||
mvi->audio_size_left = mvi->audio_data_size;
|
||||
|
||||
|
@@ -1562,11 +1562,13 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
|
||||
st->codec->bits_per_coded_sample = descriptor->bits_per_sample;
|
||||
|
||||
if (descriptor->sample_rate.den > 0) {
|
||||
avpriv_set_pts_info(st, 64, descriptor->sample_rate.den, descriptor->sample_rate.num);
|
||||
st->codec->sample_rate = descriptor->sample_rate.num / descriptor->sample_rate.den;
|
||||
avpriv_set_pts_info(st, 64, descriptor->sample_rate.den, descriptor->sample_rate.num);
|
||||
} else {
|
||||
av_log(mxf->fc, AV_LOG_WARNING, "invalid sample rate (%d/%d) found for stream #%d, time base forced to 1/48000\n",
|
||||
descriptor->sample_rate.num, descriptor->sample_rate.den, st->index);
|
||||
av_log(mxf->fc, AV_LOG_WARNING, "invalid sample rate (%d/%d) "
|
||||
"found for stream #%d, time base forced to 1/48000\n",
|
||||
descriptor->sample_rate.num, descriptor->sample_rate.den,
|
||||
st->index);
|
||||
avpriv_set_pts_info(st, 64, 1, 48000);
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -38,34 +38,35 @@ ogm_header(AVFormatContext *s, int idx)
|
||||
struct ogg *ogg = s->priv_data;
|
||||
struct ogg_stream *os = ogg->streams + idx;
|
||||
AVStream *st = s->streams[idx];
|
||||
const uint8_t *p = os->buf + os->pstart;
|
||||
GetByteContext p;
|
||||
uint64_t time_unit;
|
||||
uint64_t spu;
|
||||
uint32_t size;
|
||||
|
||||
if(!(*p & 1))
|
||||
bytestream2_init(&p, os->buf + os->pstart, os->psize);
|
||||
if (!(bytestream2_peek_byte(&p) & 1))
|
||||
return 0;
|
||||
|
||||
if(*p == 1) {
|
||||
p++;
|
||||
if (bytestream2_peek_byte(&p) == 1) {
|
||||
bytestream2_skip(&p, 1);
|
||||
|
||||
if(*p == 'v'){
|
||||
if (bytestream2_peek_byte(&p) == 'v'){
|
||||
int tag;
|
||||
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
|
||||
p += 8;
|
||||
tag = bytestream_get_le32(&p);
|
||||
bytestream2_skip(&p, 8);
|
||||
tag = bytestream2_get_le32(&p);
|
||||
st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, tag);
|
||||
st->codec->codec_tag = tag;
|
||||
} else if (*p == 't') {
|
||||
} else if (bytestream2_peek_byte(&p) == 't') {
|
||||
st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
|
||||
st->codec->codec_id = AV_CODEC_ID_TEXT;
|
||||
p += 12;
|
||||
bytestream2_skip(&p, 12);
|
||||
} else {
|
||||
uint8_t acid[5];
|
||||
uint8_t acid[5] = { 0 };
|
||||
int cid;
|
||||
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
|
||||
p += 8;
|
||||
bytestream_get_buffer(&p, acid, 4);
|
||||
bytestream2_skip(&p, 8);
|
||||
bytestream2_get_buffer(&p, acid, 4);
|
||||
acid[4] = 0;
|
||||
cid = strtol(acid, NULL, 16);
|
||||
st->codec->codec_id = ff_codec_get_id(ff_codec_wav_tags, cid);
|
||||
@@ -74,25 +75,25 @@ ogm_header(AVFormatContext *s, int idx)
|
||||
st->need_parsing = AVSTREAM_PARSE_FULL;
|
||||
}
|
||||
|
||||
size = bytestream_get_le32(&p);
|
||||
size = bytestream2_get_le32(&p);
|
||||
size = FFMIN(size, os->psize);
|
||||
time_unit = bytestream_get_le64(&p);
|
||||
spu = bytestream_get_le64(&p);
|
||||
p += 4; /* default_len */
|
||||
p += 8; /* buffersize + bits_per_sample */
|
||||
time_unit = bytestream2_get_le64(&p);
|
||||
spu = bytestream2_get_le64(&p);
|
||||
bytestream2_skip(&p, 4); /* default_len */
|
||||
bytestream2_skip(&p, 8); /* buffersize + bits_per_sample */
|
||||
|
||||
if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO){
|
||||
st->codec->width = bytestream_get_le32(&p);
|
||||
st->codec->height = bytestream_get_le32(&p);
|
||||
st->codec->width = bytestream2_get_le32(&p);
|
||||
st->codec->height = bytestream2_get_le32(&p);
|
||||
avpriv_set_pts_info(st, 64, time_unit, spu * 10000000);
|
||||
} else {
|
||||
st->codec->channels = bytestream_get_le16(&p);
|
||||
p += 2; /* block_align */
|
||||
st->codec->bit_rate = bytestream_get_le32(&p) * 8;
|
||||
st->codec->channels = bytestream2_get_le16(&p);
|
||||
bytestream2_skip(&p, 2); /* block_align */
|
||||
st->codec->bit_rate = bytestream2_get_le32(&p) * 8;
|
||||
st->codec->sample_rate = time_unit ? spu * 10000000 / time_unit : 0;
|
||||
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
|
||||
if (size >= 56 && st->codec->codec_id == AV_CODEC_ID_AAC) {
|
||||
p += 4;
|
||||
bytestream2_skip(&p, 4);
|
||||
size -= 4;
|
||||
}
|
||||
if (size > 52) {
|
||||
@@ -100,12 +101,13 @@ ogm_header(AVFormatContext *s, int idx)
|
||||
size -= 52;
|
||||
st->codec->extradata_size = size;
|
||||
st->codec->extradata = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
bytestream_get_buffer(&p, st->codec->extradata, size);
|
||||
bytestream2_get_buffer(&p, st->codec->extradata, size);
|
||||
}
|
||||
}
|
||||
} else if (*p == 3) {
|
||||
if (os->psize > 8)
|
||||
ff_vorbis_comment(s, &st->metadata, p+7, os->psize-8);
|
||||
} else if (bytestream2_peek_byte(&p) == 3) {
|
||||
bytestream2_skip(&p, 7);
|
||||
if (bytestream2_get_bytes_left(&p) > 1)
|
||||
ff_vorbis_comment(s, &st->metadata, p.buffer, bytestream2_get_bytes_left(&p) - 1);
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
@@ -169,7 +169,11 @@ static int nprobe(AVFormatContext *s, uint8_t *enc_header, unsigned size,
|
||||
taglen = AV_RB32(&enc_header[pos+32]);
|
||||
datalen = AV_RB32(&enc_header[pos+36]) >> 4;
|
||||
|
||||
pos += 44 + taglen;
|
||||
pos += 44;
|
||||
if (size - pos < taglen)
|
||||
return -1;
|
||||
|
||||
pos += taglen;
|
||||
|
||||
if (pos + (((uint64_t)datalen) << 4) > size)
|
||||
return -1;
|
||||
|
@@ -87,7 +87,7 @@ static int r3d_read_red1(AVFormatContext *s)
|
||||
|
||||
framerate.num = avio_rb16(s->pb);
|
||||
framerate.den = avio_rb16(s->pb);
|
||||
if (framerate.num && framerate.den) {
|
||||
if (framerate.num > 0 && framerate.den > 0) {
|
||||
#if FF_API_R_FRAME_RATE
|
||||
st->r_frame_rate =
|
||||
#endif
|
||||
@@ -285,6 +285,10 @@ static int r3d_read_reda(AVFormatContext *s, AVPacket *pkt, Atom *atom)
|
||||
dts = avio_rb32(s->pb);
|
||||
|
||||
st->codec->sample_rate = avio_rb32(s->pb);
|
||||
if (st->codec->sample_rate <= 0) {
|
||||
av_log(s, AV_LOG_ERROR, "Bad sample rate\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
samples = avio_rb32(s->pb);
|
||||
|
||||
|
@@ -736,6 +736,11 @@ int ff_get_wav_header(AVIOContext *pb, AVCodecContext *codec, int size)
|
||||
if (size > 0)
|
||||
avio_skip(pb, size);
|
||||
}
|
||||
if (codec->sample_rate <= 0) {
|
||||
av_log(NULL, AV_LOG_ERROR,
|
||||
"Invalid sample rate: %d\n", codec->sample_rate);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
if (codec->codec_id == AV_CODEC_ID_AAC_LATM) {
|
||||
/* channels and sample_rate values are those prior to applying SBR and/or PS */
|
||||
codec->channels = 0;
|
||||
|
@@ -107,6 +107,10 @@ static av_cold int rl2_read_header(AVFormatContext *s)
|
||||
rate = avio_rl16(pb);
|
||||
channels = avio_rl16(pb);
|
||||
def_sound_size = avio_rl16(pb);
|
||||
if (!channels || channels > 42) {
|
||||
av_log(s, AV_LOG_ERROR, "Invalid number of channels: %d\n", channels);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
/** setup video stream */
|
||||
st = avformat_new_stream(s, NULL);
|
||||
|
@@ -375,8 +375,13 @@ ff_rm_read_mdpr_codecdata (AVFormatContext *s, AVIOContext *pb,
|
||||
if ((ret = rm_read_extradata(pb, st->codec, codec_data_size - (avio_tell(pb) - codec_pos))) < 0)
|
||||
return ret;
|
||||
|
||||
av_reduce(&st->avg_frame_rate.den, &st->avg_frame_rate.num,
|
||||
0x10000, fps, (1 << 30) - 1);
|
||||
if (fps > 0) {
|
||||
av_reduce(&st->avg_frame_rate.den, &st->avg_frame_rate.num,
|
||||
0x10000, fps, (1 << 30) - 1);
|
||||
} else if (s->error_recognition & AV_EF_EXPLODE) {
|
||||
av_log(s, AV_LOG_ERROR, "Invalid framerate\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
#if FF_API_R_FRAME_RATE
|
||||
st->r_frame_rate = st->avg_frame_rate;
|
||||
#endif
|
||||
|
@@ -112,6 +112,11 @@ static int film_read_header(AVFormatContext *s)
|
||||
return AVERROR(EIO);
|
||||
film->audio_samplerate = AV_RB16(&scratch[24]);
|
||||
film->audio_channels = scratch[21];
|
||||
if (!film->audio_channels || film->audio_channels > 2) {
|
||||
av_log(s, AV_LOG_ERROR,
|
||||
"Invalid number of channels: %d\n", film->audio_channels);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
film->audio_bits = scratch[22];
|
||||
if (scratch[23] == 2 && film->audio_channels > 0)
|
||||
film->audio_type = AV_CODEC_ID_ADPCM_ADX;
|
||||
|
@@ -89,7 +89,7 @@ static int vmd_read_header(AVFormatContext *s)
|
||||
unsigned char *raw_frame_table;
|
||||
int raw_frame_table_size;
|
||||
int64_t current_offset;
|
||||
int i, j;
|
||||
int i, j, ret;
|
||||
unsigned int total_frames;
|
||||
int64_t current_audio_pts = 0;
|
||||
unsigned char chunk[BYTES_PER_FRAME_RECORD];
|
||||
@@ -176,15 +176,13 @@ static int vmd_read_header(AVFormatContext *s)
|
||||
raw_frame_table = av_malloc(raw_frame_table_size);
|
||||
vmd->frame_table = av_malloc((vmd->frame_count * vmd->frames_per_block + sound_buffers) * sizeof(vmd_frame));
|
||||
if (!raw_frame_table || !vmd->frame_table) {
|
||||
av_free(raw_frame_table);
|
||||
av_free(vmd->frame_table);
|
||||
return AVERROR(ENOMEM);
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto error;
|
||||
}
|
||||
if (avio_read(pb, raw_frame_table, raw_frame_table_size) !=
|
||||
raw_frame_table_size) {
|
||||
av_free(raw_frame_table);
|
||||
av_free(vmd->frame_table);
|
||||
return AVERROR(EIO);
|
||||
ret = AVERROR(EIO);
|
||||
goto error;
|
||||
}
|
||||
|
||||
total_frames = 0;
|
||||
@@ -200,6 +198,11 @@ static int vmd_read_header(AVFormatContext *s)
|
||||
avio_read(pb, chunk, BYTES_PER_FRAME_RECORD);
|
||||
type = chunk[0];
|
||||
size = AV_RL32(&chunk[2]);
|
||||
if (size > INT_MAX / 2) {
|
||||
av_log(s, AV_LOG_ERROR, "Invalid frame size\n");
|
||||
ret = AVERROR_INVALIDDATA;
|
||||
goto error;
|
||||
}
|
||||
if(!size && type != 1)
|
||||
continue;
|
||||
switch(type) {
|
||||
@@ -236,6 +239,11 @@ static int vmd_read_header(AVFormatContext *s)
|
||||
vmd->frame_count = total_frames;
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
av_free(raw_frame_table);
|
||||
av_free(vmd->frame_table);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int vmd_read_packet(AVFormatContext *s,
|
||||
|
@@ -329,7 +329,7 @@ static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
}
|
||||
flags >>= 1;
|
||||
}
|
||||
if (frame_size < 0)
|
||||
if (frame_size < 0 || frame_size >= INT_MAX/2)
|
||||
return AVERROR_INVALIDDATA;
|
||||
if (av_new_packet(pkt, frame_size + 769))
|
||||
return AVERROR(ENOMEM);
|
||||
@@ -345,6 +345,8 @@ static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
smk->cur_frame++;
|
||||
smk->nextpos = avio_tell(s->pb);
|
||||
} else {
|
||||
if (smk->stream_id[smk->curstream] < 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
if (av_new_packet(pkt, smk->buf_sizes[smk->curstream]))
|
||||
return AVERROR(ENOMEM);
|
||||
memcpy(pkt->data, smk->bufs[smk->curstream], smk->buf_sizes[smk->curstream]);
|
||||
|
@@ -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;
|
||||
|
@@ -2253,16 +2253,21 @@ static void fill_all_stream_timings(AVFormatContext *ic)
|
||||
static void estimate_timings_from_bit_rate(AVFormatContext *ic)
|
||||
{
|
||||
int64_t filesize, duration;
|
||||
int bit_rate, i;
|
||||
int i;
|
||||
AVStream *st;
|
||||
|
||||
/* if bit_rate is already set, we believe it */
|
||||
if (ic->bit_rate <= 0) {
|
||||
bit_rate = 0;
|
||||
int bit_rate = 0;
|
||||
for(i=0;i<ic->nb_streams;i++) {
|
||||
st = ic->streams[i];
|
||||
if (st->codec->bit_rate > 0)
|
||||
bit_rate += st->codec->bit_rate;
|
||||
if (st->codec->bit_rate > 0) {
|
||||
if (INT_MAX - st->codec->bit_rate < bit_rate) {
|
||||
bit_rate = 0;
|
||||
break;
|
||||
}
|
||||
bit_rate += st->codec->bit_rate;
|
||||
}
|
||||
}
|
||||
ic->bit_rate = bit_rate;
|
||||
}
|
||||
@@ -2977,7 +2982,8 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
|
||||
double best_error = 0.01;
|
||||
|
||||
if (st->info->codec_info_duration >= INT64_MAX / st->time_base.num / 2||
|
||||
st->info->codec_info_duration_fields >= INT64_MAX / st->time_base.den)
|
||||
st->info->codec_info_duration_fields >= INT64_MAX / st->time_base.den ||
|
||||
st->info->codec_info_duration < 0)
|
||||
continue;
|
||||
av_reduce(&st->avg_frame_rate.num, &st->avg_frame_rate.den,
|
||||
st->info->codec_info_duration_fields*(int64_t)st->time_base.den,
|
||||
|
@@ -91,11 +91,11 @@ ff_voc_get_packet(AVFormatContext *s, AVPacket *pkt, AVStream *st, int max_size)
|
||||
if (sample_rate)
|
||||
dec->sample_rate = sample_rate;
|
||||
avpriv_set_pts_info(st, 64, 1, dec->sample_rate);
|
||||
dec->channels = channels;
|
||||
dec->bits_per_coded_sample = av_get_bits_per_sample(dec->codec_id);
|
||||
} else
|
||||
avio_skip(pb, 1);
|
||||
dec->channels = channels;
|
||||
tmp_codec = avio_r8(pb);
|
||||
dec->bits_per_coded_sample = av_get_bits_per_sample(dec->codec_id);
|
||||
voc->remaining_size -= 2;
|
||||
max_size -= 2;
|
||||
channels = 1;
|
||||
@@ -117,10 +117,10 @@ ff_voc_get_packet(AVFormatContext *s, AVPacket *pkt, AVStream *st, int max_size)
|
||||
if (!dec->sample_rate) {
|
||||
dec->sample_rate = avio_rl32(pb);
|
||||
avpriv_set_pts_info(st, 64, 1, dec->sample_rate);
|
||||
dec->bits_per_coded_sample = avio_r8(pb);
|
||||
dec->channels = avio_r8(pb);
|
||||
} else
|
||||
avio_skip(pb, 4);
|
||||
dec->bits_per_coded_sample = avio_r8(pb);
|
||||
dec->channels = avio_r8(pb);
|
||||
avio_skip(pb, 6);
|
||||
tmp_codec = avio_rl16(pb);
|
||||
avio_skip(pb, 4);
|
||||
voc->remaining_size -= 12;
|
||||
|
@@ -174,6 +174,10 @@ static int vqf_read_header(AVFormatContext *s)
|
||||
st->codec->sample_rate = 11025;
|
||||
break;
|
||||
default:
|
||||
if (rate_flag < 8 || rate_flag > 44) {
|
||||
av_log(s, AV_LOG_ERROR, "Invalid rate flag %d\n", rate_flag);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
st->codec->sample_rate = rate_flag*1000;
|
||||
if (st->codec->sample_rate <= 0) {
|
||||
av_log(s, AV_LOG_ERROR, "sample rate %d is invalid\n", st->codec->sample_rate);
|
||||
@@ -182,6 +186,13 @@ static int vqf_read_header(AVFormatContext *s)
|
||||
break;
|
||||
}
|
||||
|
||||
if (read_bitrate / st->codec->channels < 8 ||
|
||||
read_bitrate / st->codec->channels > 48) {
|
||||
av_log(s, AV_LOG_ERROR, "Invalid bitrate per channel %d\n",
|
||||
read_bitrate / st->codec->channels);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
switch (((st->codec->sample_rate/1000) << 8) +
|
||||
read_bitrate/st->codec->channels) {
|
||||
case (11<<8) + 8 :
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -258,7 +258,12 @@ static AVIOContext * wtvfile_open2(AVFormatContext *s, const uint8_t *buf, int b
|
||||
dir_length = AV_RL16(buf + 16);
|
||||
file_length = AV_RL64(buf + 24);
|
||||
name_size = 2 * AV_RL32(buf + 32);
|
||||
if (buf + 48 + (int64_t)name_size > buf_end || name_size<0) {
|
||||
if (name_size < 0) {
|
||||
av_log(s, AV_LOG_ERROR,
|
||||
"bad filename length, remaining directory entries ignored\n");
|
||||
break;
|
||||
}
|
||||
if (48 + (int64_t)name_size > buf_end - buf) {
|
||||
av_log(s, AV_LOG_ERROR, "filename exceeds buffer size; remaining directory entries ignored\n");
|
||||
break;
|
||||
}
|
||||
|
@@ -49,6 +49,8 @@
|
||||
XMV_AUDIO_ADPCM51_FRONTCENTERLOW | \
|
||||
XMV_AUDIO_ADPCM51_REARLEFTRIGHT)
|
||||
|
||||
#define XMV_BLOCK_ALIGN_SIZE 36
|
||||
|
||||
/** A video packet with an XMV file. */
|
||||
typedef struct XMVVideoPacket {
|
||||
int stream_index; ///< The decoder stream index for this video packet.
|
||||
@@ -196,15 +198,10 @@ static int xmv_read_header(AVFormatContext *s)
|
||||
packet->bits_per_sample = avio_rl16(pb);
|
||||
packet->flags = avio_rl16(pb);
|
||||
|
||||
if (!packet->channels) {
|
||||
av_log(s, AV_LOG_ERROR, "0 channels\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
packet->bit_rate = packet->bits_per_sample *
|
||||
packet->sample_rate *
|
||||
packet->channels;
|
||||
packet->block_align = 36 * packet->channels;
|
||||
packet->block_align = XMV_BLOCK_ALIGN_SIZE * packet->channels;
|
||||
packet->block_samples = 64;
|
||||
packet->codec_id = ff_wav_codec_get_id(packet->compression,
|
||||
packet->bits_per_sample);
|
||||
@@ -220,7 +217,8 @@ static int xmv_read_header(AVFormatContext *s)
|
||||
av_log(s, AV_LOG_WARNING, "Unsupported 5.1 ADPCM audio stream "
|
||||
"(0x%04X)\n", packet->flags);
|
||||
|
||||
if (!packet->channels || !packet->sample_rate) {
|
||||
if (!packet->channels || !packet->sample_rate ||
|
||||
packet->channels >= UINT16_MAX / XMV_BLOCK_ALIGN_SIZE) {
|
||||
av_log(s, AV_LOG_ERROR, "Invalid parameters for audio track %d.\n",
|
||||
audio_track);
|
||||
ret = AVERROR_INVALIDDATA;
|
||||
|
@@ -201,8 +201,10 @@ static int xwma_read_header(AVFormatContext *s)
|
||||
/* Estimate the duration from the total number of output bytes. */
|
||||
const uint64_t total_decoded_bytes = dpds_table[dpds_table_size - 1];
|
||||
|
||||
if(!bytes_per_sample) {
|
||||
av_log(s, AV_LOG_ERROR, "bytes_per_sample is 0\n");
|
||||
if (!bytes_per_sample) {
|
||||
av_log(s, AV_LOG_ERROR,
|
||||
"Invalid bits_per_coded_sample %d for %d channels\n",
|
||||
st->codec->bits_per_coded_sample, st->codec->channels);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user