Compare commits
61 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
d34cfb33af | ||
![]() |
13093f9767 | ||
![]() |
fee26d352a | ||
![]() |
a23a3dba25 | ||
![]() |
0360dbefad | ||
![]() |
deb650c692 | ||
![]() |
deaaacbc3f | ||
![]() |
0b25c3b67c | ||
![]() |
10ec2308b0 | ||
![]() |
b9500bf864 | ||
![]() |
4f8f4458a5 | ||
![]() |
9def5c4666 | ||
![]() |
7aeb281aa5 | ||
![]() |
a49599b125 | ||
![]() |
fe4409a396 | ||
![]() |
c3761b6618 | ||
![]() |
2e1474fd99 | ||
![]() |
1f1b2f1806 | ||
![]() |
80f89a9b40 | ||
![]() |
5235db68c0 | ||
![]() |
6731776795 | ||
![]() |
d4e4234147 | ||
![]() |
2ae6bdbb9b | ||
![]() |
4fac60d568 | ||
![]() |
d1729c3715 | ||
![]() |
c28c631d29 | ||
![]() |
6b97e76dfc | ||
![]() |
4475a7d88b | ||
![]() |
0f6d4da8de | ||
![]() |
5c9d2d8377 | ||
![]() |
ac476bfa9f | ||
![]() |
272e7f6443 | ||
![]() |
776fb2e10d | ||
![]() |
0dfcbe5285 | ||
![]() |
6d6373dc64 | ||
![]() |
7296a6b5e9 | ||
![]() |
f695be22d8 | ||
![]() |
9125aa9218 | ||
![]() |
09a278fdd1 | ||
![]() |
9eaec5b8f0 | ||
![]() |
48ef116631 | ||
![]() |
cc511b36f3 | ||
![]() |
85b22a8924 | ||
![]() |
6ec1d3b3ba | ||
![]() |
d843e7dc94 | ||
![]() |
acc665f22c | ||
![]() |
4c223fe519 | ||
![]() |
5a9588b088 | ||
![]() |
02cd93f4ad | ||
![]() |
f8a31e2113 | ||
![]() |
8ba939fcda | ||
![]() |
79674d27d9 | ||
![]() |
b061ee9a5d | ||
![]() |
baba561c0b | ||
![]() |
f6147effd2 | ||
![]() |
b990187f99 | ||
![]() |
ae6c57859c | ||
![]() |
5629c39101 | ||
![]() |
7867cbaf6c | ||
![]() |
0bf8e22cdb | ||
![]() |
7944a87ba8 |
48
Changelog
48
Changelog
@@ -1,6 +1,54 @@
|
||||
Entries are sorted chronologically from oldest to youngest within each release,
|
||||
releases are sorted from youngest to oldest.
|
||||
|
||||
version 0.5.10:
|
||||
|
||||
- mpeg12: do not decode extradata more than once (CVE-2012-2803)
|
||||
- vp6: properly fail on unsupported feature (CVE-2012-2783)
|
||||
- vp56: release frames on error (CVE-2012-2783)
|
||||
- shorten: Use separate pointers for the allocated memory for decoded samples (CVE-2012-0858)
|
||||
- shorten: check for realloc failure
|
||||
- h264: check context state before decoding slice data partitions
|
||||
- oggdec: check memory allocation
|
||||
- Fix uninitialized reads on malformed Ogg files
|
||||
- lavf: avoid integer overflow in ff_compute_frame_duration()
|
||||
- yuv4mpeg: reject unsupported codecs
|
||||
- tiffenc: Check av_malloc() results
|
||||
- mpegaudiodec: fix short_start calculation
|
||||
- h264: avoid stuck buffer pointer in decode_nal_units
|
||||
- yuv4mpeg: return proper error codes (Bug 373)
|
||||
- avidec: return 0, not packet size from read_packet()
|
||||
- cavsdec: check for changing w/h (CVE-2012-2777 and CVE-2012-2784)
|
||||
- avidec: use actually read size instead of requested size CVE-2012-2788
|
||||
- bytestream: add a new set of bytestream functions with overread checking
|
||||
- avsdec: Set dimensions instead of relying on the demuxer (CVE-2012-2801)
|
||||
- lavfi: avfilter_merge_formats: handle case where inputs are same
|
||||
- bmpdec: only initialize palette for pal8 (Bug 367)
|
||||
- Bump version number for the 0.5.10 release
|
||||
- lavfi: avfilter_merge_formats: handle case where inputs are same
|
||||
- mpegvideo: Don't use ff_mspel_motion() for vc1
|
||||
- imgconvert: avoid undefined left shift in avcodec_find_best_pix_fmt
|
||||
- nuv: check RTjpeg header for validity
|
||||
- vc1dec: add flush function for WMV9 and VC-1 decoders
|
||||
|
||||
|
||||
version 0.5.9:
|
||||
|
||||
- dpcm: ignore extra unpaired bytes in stereo streams (CVE-2011-3951)
|
||||
- h264: Add check for invalid chroma_format_idc (CVE-2012-0851)
|
||||
- adpcm: ADPCM Electronic Arts has always two channels (CVE-2012-0852)
|
||||
- kmvc: Check palsize (CVE-2011-3952)
|
||||
- qdm2: clip array indices returned by qdm2_get_vlc()
|
||||
- configure: properly check for mingw-w64 through installed headers
|
||||
- Replace every usage of -lvfw32 with what is particularly necessary for that case
|
||||
- mingw32: properly check if vfw capture is supported by the system headers
|
||||
- mingw32: merge checks for mingw-w64 and mingw32-runtime >= 3.15 into one
|
||||
- vfwcap: Include windows.h before vfw.h since the latter requires defines from the former
|
||||
- ea: check chunk_size for validity
|
||||
- eatqi: move "block" variable into context to ensure sufficient alignment for idct_put
|
||||
- tqi: Pass errors from the MB decoder
|
||||
- png: check bit depth for PAL8/Y400A pixel formats.
|
||||
|
||||
|
||||
version 0.5.8:
|
||||
|
||||
|
39
RELEASE
39
RELEASE
@@ -198,6 +198,8 @@ Distributors and system integrators are encouraged
|
||||
to update and share their patches against this branch. For a full list
|
||||
of changes please see the Changelog file.
|
||||
|
||||
|
||||
|
||||
* 0.5.9 May 11, 2012
|
||||
|
||||
General notes
|
||||
@@ -213,3 +215,40 @@ security issues that have been brought to our attention. Among other
|
||||
Distributors and system integrators are encouraged
|
||||
to update and share their patches against this branch. For a full list
|
||||
of changes please see the Changelog file.
|
||||
|
||||
|
||||
|
||||
* 0.5.10 Jun 09, 2012
|
||||
|
||||
General notes
|
||||
-------------
|
||||
|
||||
This mostly maintenance-only release addresses a number of bugs such as
|
||||
security and compilation issues that have been brought to our
|
||||
attention. Among other fixes, this release includes security updates for
|
||||
the DPCM codecs (CVE-2011-3951), H.264 (CVE-2012-0851), ADPCM
|
||||
(CVE-2012-0852), and the KMVC decoder (CVE-2011-3952).
|
||||
|
||||
Distributors and system integrators are encouraged to update and share
|
||||
their patches against this branch. For a full list of changes please see
|
||||
the Changelog file or the Git commit history.
|
||||
|
||||
|
||||
|
||||
* 0.5.11 Feb 17, 2013
|
||||
|
||||
General notes
|
||||
-------------
|
||||
|
||||
This maintenance-only release addresses a number of bugs such as
|
||||
security and compilation issues that have been brought to our
|
||||
attention. Among other fixes, this release includes security updates for
|
||||
the mpeg12 codecs (CVE-2012-2803), H.264, VP5/VP6 (CVE-2012-2783,
|
||||
CVE-2012-2783), shorten (CVE-2012-0858), CAVS (CVE-2012-2777 and
|
||||
CVE-2012-2784), AVS (CVE-2012-2801) and a number of additional safe but
|
||||
important bugs in other decoders. Additionally, reported bugs in the
|
||||
yuv4mpeg (Bug 373) and BMP decoder (Bug 367) have been addressed.
|
||||
|
||||
Distributors and system integrators are encouraged to update and share
|
||||
their patches against this branch. For a full list of changes please
|
||||
see the Changelog file or the Git commit history.
|
||||
|
@@ -50,7 +50,7 @@ AVCodecContext *avctx_opts[CODEC_TYPE_NB];
|
||||
AVFormatContext *avformat_opts;
|
||||
struct SwsContext *sws_opts;
|
||||
|
||||
const int this_year = 2009;
|
||||
const int this_year = 2013;
|
||||
|
||||
double parse_number_or_die(const char *context, const char *numstr, int type, double min, double max)
|
||||
{
|
||||
|
19
configure
vendored
19
configure
vendored
@@ -1131,8 +1131,8 @@ rtsp_demuxer_deps="sdp_demuxer"
|
||||
sdp_demuxer_deps="rtp_protocol mpegts_demuxer"
|
||||
v4l_demuxer_deps="linux_videodev_h"
|
||||
v4l2_demuxer_deps_any="linux_videodev2_h sys_videoio_h"
|
||||
vfwcap_demuxer_deps="capCreateCaptureWindow"
|
||||
vfwcap_demuxer_extralibs="-lvfw32"
|
||||
vfwcap_demuxer_deps="capCreateCaptureWindow vfwcap_defines"
|
||||
vfwcap_demuxer_extralibs="-lavicap32"
|
||||
x11_grab_device_demuxer_deps="x11grab XShmCreateImage"
|
||||
x11_grab_device_demuxer_extralibs="-lX11 -lXext"
|
||||
|
||||
@@ -1611,13 +1611,9 @@ case $target_os in
|
||||
objformat="win32"
|
||||
enable dos_paths
|
||||
check_cflags -fno-common
|
||||
if ! enabled x86_64; then
|
||||
check_cpp_condition _mingw.h "(__MINGW32_MAJOR_VERSION > 3) || (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
|
||||
check_cpp_condition _mingw.h "defined (__MINGW64_VERSION_MAJOR) || (__MINGW32_MAJOR_VERSION > 3) \
|
||||
|| (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
|
||||
die "ERROR: MinGW runtime version must be >= 3.15."
|
||||
enabled_any avisynth vfwcap_demuxer &&
|
||||
{ check_cpp_condition w32api.h "(__W32API_MAJOR_VERSION > 3) || (__W32API_MAJOR_VERSION == 3 && __W32API_MINOR_VERSION >= 13)" ||
|
||||
die "ERROR: avisynth and vfwcap_demuxer require w32api version 3.13 or later."; }
|
||||
fi
|
||||
;;
|
||||
cygwin*)
|
||||
target_os=cygwin
|
||||
@@ -2022,7 +2018,7 @@ EOF
|
||||
done
|
||||
|
||||
# these are off by default, so fail if requested and not available
|
||||
enabled avisynth && require2 vfw32 "windows.h vfw.h" AVIFileInit -lvfw32
|
||||
enabled avisynth && require2 vfw32 "windows.h vfw.h" AVIFileInit -lavifil32
|
||||
enabled libamr_nb && require libamrnb amrnb/interf_dec.h Speech_Decode_Frame_init -lamrnb -lm
|
||||
enabled libamr_wb && require libamrwb amrwb/dec_if.h D_IF_init -lamrwb -lm
|
||||
enabled libdirac && add_cflags $(pkg-config --cflags dirac) &&
|
||||
@@ -2149,7 +2145,10 @@ check_header linux/videodev.h
|
||||
check_header linux/videodev2.h
|
||||
check_header sys/videoio.h
|
||||
|
||||
check_func_headers "windows.h vfw.h" capCreateCaptureWindow -lvfw32
|
||||
check_func_headers "windows.h vfw.h" capCreateCaptureWindow -lavicap32
|
||||
# check that WM_CAP_DRIVER_CONNECT is defined to the proper value
|
||||
# w32api 3.12 had it defined wrong
|
||||
check_cpp_condition vfw.h "WM_CAP_DRIVER_CONNECT > WM_USER" && enable vfwcap_defines
|
||||
|
||||
# check for ioctl_meteor.h, ioctl_bt848.h and alternatives
|
||||
{ check_header dev/bktr/ioctl_meteor.h &&
|
||||
|
@@ -667,17 +667,23 @@ static int adpcm_encode_frame(AVCodecContext *avctx,
|
||||
static av_cold int adpcm_decode_init(AVCodecContext * avctx)
|
||||
{
|
||||
ADPCMContext *c = avctx->priv_data;
|
||||
unsigned int min_channels = 1;
|
||||
unsigned int max_channels = 2;
|
||||
|
||||
switch(avctx->codec->id) {
|
||||
case CODEC_ID_ADPCM_EA:
|
||||
min_channels = 2;
|
||||
break;
|
||||
case CODEC_ID_ADPCM_EA_R1:
|
||||
case CODEC_ID_ADPCM_EA_R2:
|
||||
case CODEC_ID_ADPCM_EA_R3:
|
||||
max_channels = 6;
|
||||
break;
|
||||
}
|
||||
if(avctx->channels > max_channels){
|
||||
return -1;
|
||||
|
||||
if (avctx->channels < min_channels || avctx->channels > max_channels) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Invalid number of channels\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
switch(avctx->codec->id) {
|
||||
|
@@ -145,6 +145,7 @@ avs_decode_frame(AVCodecContext * avctx,
|
||||
static av_cold int avs_decode_init(AVCodecContext * avctx)
|
||||
{
|
||||
avctx->pix_fmt = PIX_FMT_PAL8;
|
||||
avcodec_set_dimensions(avctx, 318, 198);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -217,9 +217,6 @@ static int bmp_decode_frame(AVCodecContext *avctx,
|
||||
if(comp == BMP_RLE4 || comp == BMP_RLE8)
|
||||
memset(p->data[0], 0, avctx->height * p->linesize[0]);
|
||||
|
||||
if(depth == 4 || depth == 8)
|
||||
memset(p->data[1], 0, 1024);
|
||||
|
||||
if(height > 0){
|
||||
ptr = p->data[0] + (avctx->height - 1) * p->linesize[0];
|
||||
linesize = -p->linesize[0];
|
||||
@@ -229,6 +226,9 @@ static int bmp_decode_frame(AVCodecContext *avctx,
|
||||
}
|
||||
|
||||
if(avctx->pix_fmt == PIX_FMT_PAL8){
|
||||
|
||||
memset(p->data[1], 0, 1024);
|
||||
|
||||
buf = buf0 + 14 + ihsize; //palette location
|
||||
if((hsize-ihsize-14)>>depth < 4){ // OS/2 bitmap, 3 bytes per palette entry
|
||||
for(i = 0; i < (1 << depth); i++)
|
||||
|
@@ -26,6 +26,10 @@
|
||||
#include "libavutil/common.h"
|
||||
#include "libavutil/intreadwrite.h"
|
||||
|
||||
typedef struct {
|
||||
const uint8_t *buffer, *buffer_end;
|
||||
} GetByteContext;
|
||||
|
||||
#define DEF_T(type, name, bytes, read, write) \
|
||||
static av_always_inline type bytestream_get_ ## name(const uint8_t **b){\
|
||||
(*b) += bytes;\
|
||||
@@ -34,6 +38,18 @@ static av_always_inline type bytestream_get_ ## name(const uint8_t **b){\
|
||||
static av_always_inline void bytestream_put_ ##name(uint8_t **b, const type value){\
|
||||
write(*b, value);\
|
||||
(*b) += bytes;\
|
||||
}\
|
||||
static av_always_inline type bytestream2_get_ ## name(GetByteContext *g)\
|
||||
{\
|
||||
if (g->buffer_end - g->buffer < bytes)\
|
||||
return 0;\
|
||||
return bytestream_get_ ## name(&g->buffer);\
|
||||
}\
|
||||
static av_always_inline type bytestream2_peek_ ## name(GetByteContext *g)\
|
||||
{\
|
||||
if (g->buffer_end - g->buffer < bytes)\
|
||||
return 0;\
|
||||
return read(g->buffer);\
|
||||
}
|
||||
|
||||
#define DEF(name, bytes, read, write) \
|
||||
@@ -55,6 +71,34 @@ DEF (byte, 1, AV_RB8 , AV_WB8 )
|
||||
#undef DEF64
|
||||
#undef DEF_T
|
||||
|
||||
static av_always_inline void bytestream2_init(GetByteContext *g,
|
||||
const uint8_t *buf, int buf_size)
|
||||
{
|
||||
g->buffer = buf;
|
||||
g->buffer_end = buf + buf_size;
|
||||
}
|
||||
|
||||
static av_always_inline unsigned int bytestream2_get_bytes_left(GetByteContext *g)
|
||||
{
|
||||
return g->buffer_end - g->buffer;
|
||||
}
|
||||
|
||||
static av_always_inline void bytestream2_skip(GetByteContext *g,
|
||||
unsigned int size)
|
||||
{
|
||||
g->buffer += FFMIN(g->buffer_end - g->buffer, size);
|
||||
}
|
||||
|
||||
static av_always_inline unsigned int bytestream2_get_buffer(GetByteContext *g,
|
||||
uint8_t *dst,
|
||||
unsigned int size)
|
||||
{
|
||||
int size2 = FFMIN(g->buffer_end - g->buffer, size);
|
||||
memcpy(dst, g->buffer, size2);
|
||||
g->buffer += size2;
|
||||
return size2;
|
||||
}
|
||||
|
||||
static av_always_inline unsigned int bytestream_get_buffer(const uint8_t **b, uint8_t *dst, unsigned int size)
|
||||
{
|
||||
memcpy(dst, *b, size);
|
||||
|
@@ -599,12 +599,21 @@ static int decode_pic(AVSContext *h) {
|
||||
static int decode_seq_header(AVSContext *h) {
|
||||
MpegEncContext *s = &h->s;
|
||||
int frame_rate_code;
|
||||
int width, height;
|
||||
|
||||
h->profile = get_bits(&s->gb,8);
|
||||
h->level = get_bits(&s->gb,8);
|
||||
skip_bits1(&s->gb); //progressive sequence
|
||||
s->width = get_bits(&s->gb,14);
|
||||
s->height = get_bits(&s->gb,14);
|
||||
|
||||
width = get_bits(&s->gb, 14);
|
||||
height = get_bits(&s->gb, 14);
|
||||
if ((s->width || s->height) && (s->width != width || s->height != height)) {
|
||||
av_log(s, AV_LOG_ERROR, "Width/height changing in CAVS is unsupported");
|
||||
return AVERROR_PATCHWELCOME;
|
||||
}
|
||||
s->width = width;
|
||||
s->height = height;
|
||||
|
||||
skip_bits(&s->gb,2); //chroma format
|
||||
skip_bits(&s->gb,3); //sample_precision
|
||||
h->aspect_ratio = get_bits(&s->gb,4);
|
||||
|
@@ -167,6 +167,7 @@ static int dpcm_decode_frame(AVCodecContext *avctx,
|
||||
int in, out = 0;
|
||||
int predictor[2];
|
||||
int channel_number = 0;
|
||||
int stereo = s->channels - 1;
|
||||
short *output_samples = data;
|
||||
int shift[2];
|
||||
unsigned char byte;
|
||||
@@ -175,6 +176,9 @@ static int dpcm_decode_frame(AVCodecContext *avctx,
|
||||
if (!buf_size)
|
||||
return 0;
|
||||
|
||||
if (stereo && (buf_size & 1))
|
||||
buf_size--;
|
||||
|
||||
// almost every DPCM variant expands one byte of data into two
|
||||
if(*data_size/2 < buf_size)
|
||||
return -1;
|
||||
|
@@ -40,6 +40,7 @@ typedef struct TqiContext {
|
||||
AVFrame frame;
|
||||
uint8_t *bitstream_buf;
|
||||
unsigned int bitstream_buf_size;
|
||||
DECLARE_ALIGNED_16(DCTELEM, block[6][64]);
|
||||
} TqiContext;
|
||||
|
||||
static av_cold int tqi_decode_init(AVCodecContext *avctx)
|
||||
@@ -58,12 +59,15 @@ static av_cold int tqi_decode_init(AVCodecContext *avctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void tqi_decode_mb(MpegEncContext *s, DCTELEM (*block)[64])
|
||||
static int tqi_decode_mb(MpegEncContext *s, DCTELEM (*block)[64])
|
||||
{
|
||||
int n;
|
||||
s->dsp.clear_blocks(block[0]);
|
||||
for (n=0; n<6; n++)
|
||||
ff_mpeg1_decode_block_intra(s, block[n], n);
|
||||
if (ff_mpeg1_decode_block_intra(s, block[n], n) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void tqi_idct_put(TqiContext *t, DCTELEM (*block)[64])
|
||||
@@ -106,7 +110,6 @@ static int tqi_decode_frame(AVCodecContext *avctx,
|
||||
const uint8_t *buf_end = buf+buf_size;
|
||||
TqiContext *t = avctx->priv_data;
|
||||
MpegEncContext *s = &t->s;
|
||||
DECLARE_ALIGNED_16(DCTELEM, block[6][64]);
|
||||
|
||||
s->width = AV_RL16(&buf[0]);
|
||||
s->height = AV_RL16(&buf[2]);
|
||||
@@ -134,8 +137,9 @@ static int tqi_decode_frame(AVCodecContext *avctx,
|
||||
for (s->mb_y=0; s->mb_y<(avctx->height+15)/16; s->mb_y++)
|
||||
for (s->mb_x=0; s->mb_x<(avctx->width+15)/16; s->mb_x++)
|
||||
{
|
||||
tqi_decode_mb(s, block);
|
||||
tqi_idct_put(t, block);
|
||||
if (tqi_decode_mb(s, t->block) < 0)
|
||||
break;
|
||||
tqi_idct_put(t, t->block);
|
||||
}
|
||||
|
||||
*data_size = sizeof(AVFrame);
|
||||
|
@@ -7134,8 +7134,12 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){
|
||||
|
||||
if(sps->profile_idc >= 100){ //high profile
|
||||
sps->chroma_format_idc= get_ue_golomb_31(&s->gb);
|
||||
if(sps->chroma_format_idc == 3)
|
||||
if(sps->chroma_format_idc > 3) {
|
||||
av_log(h->s.avctx, AV_LOG_ERROR, "chroma_format_idc (%u) out of range\n", sps->chroma_format_idc);
|
||||
return -1;
|
||||
} else if(sps->chroma_format_idc == 3) {
|
||||
sps->residual_color_transform_flag = get_bits1(&s->gb);
|
||||
}
|
||||
sps->bit_depth_luma = get_ue_golomb(&s->gb) + 8;
|
||||
sps->bit_depth_chroma = get_ue_golomb(&s->gb) + 8;
|
||||
sps->transform_bypass = get_bits1(&s->gb);
|
||||
@@ -7455,7 +7459,11 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){
|
||||
break;
|
||||
}
|
||||
|
||||
if(buf_index+3 >= buf_size) break;
|
||||
|
||||
if (buf_index + 3 >= buf_size) {
|
||||
buf_index = buf_size;
|
||||
break;
|
||||
}
|
||||
|
||||
buf_index+=3;
|
||||
}
|
||||
@@ -7549,6 +7557,7 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){
|
||||
hx->inter_gb_ptr= &hx->inter_gb;
|
||||
|
||||
if(hx->redundant_pic_count==0 && hx->intra_gb_ptr && hx->s.data_partitioning
|
||||
&& s->current_picture_ptr
|
||||
&& s->context_initialized
|
||||
&& s->hurry_up < 5
|
||||
&& (avctx->skip_frame < AVDISCARD_NONREF || hx->nal_ref_idc)
|
||||
|
@@ -312,12 +312,13 @@ static void generate_joint_tables(HYuvContext *s){
|
||||
for(i=y=0; y<256; y++){
|
||||
int len0 = s->len[0][y];
|
||||
int limit = VLC_BITS - len0;
|
||||
if(limit <= 0)
|
||||
if(limit <= 0 || !len0)
|
||||
continue;
|
||||
for(u=0; u<256; u++){
|
||||
int len1 = s->len[p][u];
|
||||
if(len1 > limit)
|
||||
if (len1 > limit || !len1)
|
||||
continue;
|
||||
assert(i < (1 << VLC_BITS));
|
||||
len[i] = len0 + len1;
|
||||
bits[i] = (s->bits[0][y] << len1) + s->bits[p][u];
|
||||
symbols[i] = (y<<8) + u;
|
||||
@@ -339,18 +340,19 @@ static void generate_joint_tables(HYuvContext *s){
|
||||
for(i=0, g=-16; g<16; g++){
|
||||
int len0 = s->len[p0][g&255];
|
||||
int limit0 = VLC_BITS - len0;
|
||||
if(limit0 < 2)
|
||||
if (limit0 < 2 || !len0)
|
||||
continue;
|
||||
for(b=-16; b<16; b++){
|
||||
int len1 = s->len[p1][b&255];
|
||||
int limit1 = limit0 - len1;
|
||||
if(limit1 < 1)
|
||||
if (limit1 < 1 || !len1)
|
||||
continue;
|
||||
code = (s->bits[p0][g&255] << len1) + s->bits[p1][b&255];
|
||||
for(r=-16; r<16; r++){
|
||||
int len2 = s->len[2][r&255];
|
||||
if(len2 > limit1)
|
||||
if (len2 > limit1 || !len2)
|
||||
continue;
|
||||
assert(i < (1 << VLC_BITS));
|
||||
len[i] = len0 + len1 + len2;
|
||||
bits[i] = (code << len2) + s->bits[2][r&255];
|
||||
if(s->decorrelate){
|
||||
@@ -374,6 +376,7 @@ static void generate_joint_tables(HYuvContext *s){
|
||||
static int read_huffman_tables(HYuvContext *s, uint8_t *src, int length){
|
||||
GetBitContext gb;
|
||||
int i;
|
||||
int ret;
|
||||
|
||||
init_get_bits(&gb, src, length*8);
|
||||
|
||||
@@ -389,7 +392,8 @@ printf("%6X, %2d, %3d\n", s->bits[i][j], s->len[i][j], j);
|
||||
}
|
||||
#endif
|
||||
free_vlc(&s->vlc[i]);
|
||||
init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, s->bits[i], 4, 4, 0);
|
||||
if ((ret = init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, s->bits[i], 4, 4, 0)) < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
generate_joint_tables(s);
|
||||
@@ -401,6 +405,7 @@ static int read_old_huffman_tables(HYuvContext *s){
|
||||
#if 1
|
||||
GetBitContext gb;
|
||||
int i;
|
||||
int ret;
|
||||
|
||||
init_get_bits(&gb, classic_shift_luma, sizeof(classic_shift_luma)*8);
|
||||
read_len_table(s->len[0], &gb);
|
||||
@@ -419,7 +424,8 @@ static int read_old_huffman_tables(HYuvContext *s){
|
||||
|
||||
for(i=0; i<3; i++){
|
||||
free_vlc(&s->vlc[i]);
|
||||
init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, s->bits[i], 4, 4, 0);
|
||||
if ((ret = init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, s->bits[i], 4, 4, 0)) < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
generate_joint_tables(s);
|
||||
|
@@ -890,7 +890,8 @@ static int avcodec_find_best_pix_fmt1(int64_t pix_fmt_mask,
|
||||
/* find exact color match with smallest size */
|
||||
dst_pix_fmt = -1;
|
||||
min_dist = 0x7fffffff;
|
||||
for(i = 0;i < PIX_FMT_NB; i++) {
|
||||
/* test only the first 64 pixel formats to avoid undefined behaviour */
|
||||
for (i = 0; i < 64; i++) {
|
||||
if (pix_fmt_mask & (1ULL << i)) {
|
||||
loss = avcodec_get_pix_fmt_loss(i, src_pix_fmt, has_alpha) & loss_mask;
|
||||
if (loss == 0) {
|
||||
|
@@ -33,6 +33,7 @@
|
||||
#define KMVC_KEYFRAME 0x80
|
||||
#define KMVC_PALETTE 0x40
|
||||
#define KMVC_METHOD 0x0F
|
||||
#define MAX_PALSIZE 256
|
||||
|
||||
/*
|
||||
* Decoder context
|
||||
@@ -43,7 +44,7 @@ typedef struct KmvcContext {
|
||||
|
||||
int setpal;
|
||||
int palsize;
|
||||
uint32_t pal[256];
|
||||
uint32_t pal[MAX_PALSIZE];
|
||||
uint8_t *cur, *prev;
|
||||
uint8_t *frm0, *frm1;
|
||||
} KmvcContext;
|
||||
@@ -366,6 +367,10 @@ static av_cold int decode_init(AVCodecContext * avctx)
|
||||
c->palsize = 127;
|
||||
} else {
|
||||
c->palsize = AV_RL16(avctx->extradata + 10);
|
||||
if (c->palsize >= MAX_PALSIZE) {
|
||||
av_log(avctx, AV_LOG_ERROR, "KMVC palette too large\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
}
|
||||
|
||||
if (avctx->extradata_size == 1036) { // palette in extradata
|
||||
|
@@ -1163,6 +1163,7 @@ typedef struct Mpeg1Context {
|
||||
int save_width, save_height;
|
||||
AVRational frame_rate_ext; ///< MPEG-2 specific framerate modificator
|
||||
|
||||
int extradata_decoded;
|
||||
} Mpeg1Context;
|
||||
|
||||
static av_cold int mpeg_decode_init(AVCodecContext *avctx)
|
||||
@@ -2299,8 +2300,10 @@ static int mpeg_decode_frame(AVCodecContext *avctx,
|
||||
|
||||
s->slice_count= 0;
|
||||
|
||||
if(avctx->extradata && !avctx->frame_number)
|
||||
if (avctx->extradata && !s->extradata_decoded) {
|
||||
decode_chunks(avctx, picture, data_size, avctx->extradata, avctx->extradata_size);
|
||||
s->extradata_decoded = 1;
|
||||
}
|
||||
|
||||
return decode_chunks(avctx, picture, data_size, buf, buf_size);
|
||||
}
|
||||
|
@@ -173,7 +173,7 @@ void ff_compute_band_indexes(MPADecodeContext *s, GranuleDef *g){
|
||||
else
|
||||
g->long_end = 4; /* 8000 Hz */
|
||||
|
||||
g->short_start = 2 + (s->sample_rate_index != 8);
|
||||
g->short_start = 3;
|
||||
} else {
|
||||
g->long_end = 0;
|
||||
g->short_start = 0;
|
||||
|
@@ -727,7 +727,7 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s,
|
||||
0, 0, 0,
|
||||
ref_picture, pix_op, qpix_op,
|
||||
s->mv[dir][0][0], s->mv[dir][0][1], 16);
|
||||
}else if(!is_mpeg12 && CONFIG_WMV2 && s->mspel){
|
||||
}else if(!is_mpeg12 && CONFIG_WMV2 && s->mspel && s->codec_id == CODEC_ID_WMV2){
|
||||
ff_mspel_motion(s, dest_y, dest_cb, dest_cr,
|
||||
ref_picture, pix_op,
|
||||
s->mv[dir][0][0], s->mv[dir][0][1], 16);
|
||||
|
@@ -182,17 +182,18 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
|
||||
}
|
||||
if (c->codec_frameheader) {
|
||||
int w, h, q;
|
||||
if (buf_size < 12) {
|
||||
if (buf_size < RTJPEG_HEADER_SIZE || buf[4] != RTJPEG_HEADER_SIZE ||
|
||||
buf[5] != RTJPEG_FILE_VERSION) {
|
||||
av_log(avctx, AV_LOG_ERROR, "invalid nuv video frame\n");
|
||||
return -1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
w = AV_RL16(&buf[6]);
|
||||
h = AV_RL16(&buf[8]);
|
||||
q = buf[10];
|
||||
if (!codec_reinit(avctx, w, h, q))
|
||||
return -1;
|
||||
buf = &buf[12];
|
||||
buf_size -= 12;
|
||||
buf = &buf[RTJPEG_HEADER_SIZE];
|
||||
buf_size -= RTJPEG_HEADER_SIZE;
|
||||
}
|
||||
|
||||
if (keyframe && c->pic.data[0])
|
||||
|
@@ -473,7 +473,8 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
} else if (s->bit_depth == 1 &&
|
||||
s->color_type == PNG_COLOR_TYPE_GRAY) {
|
||||
avctx->pix_fmt = PIX_FMT_MONOBLACK;
|
||||
} else if (s->color_type == PNG_COLOR_TYPE_PALETTE) {
|
||||
} else if (s->bit_depth == 8 &&
|
||||
s->color_type == PNG_COLOR_TYPE_PALETTE) {
|
||||
avctx->pix_fmt = PIX_FMT_PAL8;
|
||||
} else {
|
||||
goto fail;
|
||||
|
@@ -905,9 +905,13 @@ static void synthfilt_build_sb_samples (QDM2Context *q, GetBitContext *gb, int l
|
||||
break;
|
||||
|
||||
case 30:
|
||||
if (BITS_LEFT(length,gb) >= 4)
|
||||
samples[0] = type30_dequant[qdm2_get_vlc(gb, &vlc_tab_type30, 0, 1)];
|
||||
else
|
||||
if (BITS_LEFT(length,gb) >= 4) {
|
||||
unsigned index = qdm2_get_vlc(gb, &vlc_tab_type30, 0, 1);
|
||||
if (index < FF_ARRAY_ELEMS(type30_dequant)) {
|
||||
samples[0] = type30_dequant[index];
|
||||
} else
|
||||
samples[0] = SB_DITHERING_NOISE(sb,q->noise_idx);
|
||||
} else
|
||||
samples[0] = SB_DITHERING_NOISE(sb,q->noise_idx);
|
||||
|
||||
run = 1;
|
||||
@@ -921,8 +925,12 @@ static void synthfilt_build_sb_samples (QDM2Context *q, GetBitContext *gb, int l
|
||||
type34_predictor = samples[0];
|
||||
type34_first = 0;
|
||||
} else {
|
||||
samples[0] = type34_delta[qdm2_get_vlc(gb, &vlc_tab_type34, 0, 1)] / type34_div + type34_predictor;
|
||||
type34_predictor = samples[0];
|
||||
unsigned index = qdm2_get_vlc(gb, &vlc_tab_type34, 0, 1);
|
||||
if (index < FF_ARRAY_ELEMS(type34_delta)) {
|
||||
samples[0] = type34_delta[index] / type34_div + type34_predictor;
|
||||
type34_predictor = samples[0];
|
||||
} else
|
||||
samples[0] = SB_DITHERING_NOISE(sb,q->noise_idx);
|
||||
}
|
||||
} else {
|
||||
samples[0] = SB_DITHERING_NOISE(sb,q->noise_idx);
|
||||
@@ -1254,6 +1262,11 @@ static void qdm2_decode_super_block (QDM2Context *q)
|
||||
for (i = 0; packet_bytes > 0; i++) {
|
||||
int j;
|
||||
|
||||
if (i>=FF_ARRAY_ELEMS(q->sub_packet_list_A)) {
|
||||
SAMPLES_NEEDED_2("too many packet bytes");
|
||||
return;
|
||||
}
|
||||
|
||||
q->sub_packet_list_A[i].next = NULL;
|
||||
|
||||
if (i > 0) {
|
||||
|
@@ -158,6 +158,12 @@ static av_cold int roq_decode_init(AVCodecContext *avctx)
|
||||
RoqContext *s = avctx->priv_data;
|
||||
|
||||
s->avctx = avctx;
|
||||
|
||||
if (avctx->width%16 || avctx->height%16) {
|
||||
av_log(avctx, AV_LOG_ERROR, "dimensions not being a multiple of 16 are unsupported\n");
|
||||
return AVERROR_PATCHWELCOME;
|
||||
}
|
||||
|
||||
s->width = avctx->width;
|
||||
s->height = avctx->height;
|
||||
s->last_frame = &s->frames[0];
|
||||
|
@@ -25,6 +25,9 @@
|
||||
#include <stdint.h>
|
||||
#include "dsputil.h"
|
||||
|
||||
#define RTJPEG_FILE_VERSION 0
|
||||
#define RTJPEG_HEADER_SIZE 12
|
||||
|
||||
typedef struct {
|
||||
int w, h;
|
||||
DSPContext *dsp;
|
||||
|
@@ -82,6 +82,7 @@ typedef struct ShortenContext {
|
||||
int channels;
|
||||
|
||||
int32_t *decoded[MAX_CHANNELS];
|
||||
int32_t *decoded_base[MAX_CHANNELS];
|
||||
int32_t *offset[MAX_CHANNELS];
|
||||
uint8_t *bitstream;
|
||||
int bitstream_size;
|
||||
@@ -112,6 +113,8 @@ static av_cold int shorten_decode_init(AVCodecContext * avctx)
|
||||
static int allocate_buffers(ShortenContext *s)
|
||||
{
|
||||
int i, chan;
|
||||
void *tmp_ptr;
|
||||
|
||||
for (chan=0; chan<s->channels; chan++) {
|
||||
if(FFMAX(1, s->nmean) >= UINT_MAX/sizeof(int32_t)){
|
||||
av_log(s->avctx, AV_LOG_ERROR, "nmean too large\n");
|
||||
@@ -122,12 +125,19 @@ static int allocate_buffers(ShortenContext *s)
|
||||
return -1;
|
||||
}
|
||||
|
||||
s->offset[chan] = av_realloc(s->offset[chan], sizeof(int32_t)*FFMAX(1, s->nmean));
|
||||
tmp_ptr = av_realloc(s->offset[chan], sizeof(int32_t)*FFMAX(1, s->nmean));
|
||||
if (!tmp_ptr)
|
||||
return AVERROR(ENOMEM);
|
||||
s->offset[chan] = tmp_ptr;
|
||||
|
||||
s->decoded[chan] = av_realloc(s->decoded[chan], sizeof(int32_t)*(s->blocksize + s->nwrap));
|
||||
tmp_ptr = av_realloc(s->decoded_base[chan], (s->blocksize + s->nwrap) *
|
||||
sizeof(s->decoded_base[0][0]));
|
||||
if (!tmp_ptr)
|
||||
return AVERROR(ENOMEM);
|
||||
s->decoded_base[chan] = tmp_ptr;
|
||||
for (i=0; i<s->nwrap; i++)
|
||||
s->decoded[chan][i] = 0;
|
||||
s->decoded[chan] += s->nwrap;
|
||||
s->decoded_base[chan][i] = 0;
|
||||
s->decoded[chan] = s->decoded_base[chan] + s->nwrap;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -275,8 +285,15 @@ static int shorten_decode_frame(AVCodecContext *avctx,
|
||||
int i, input_buf_size = 0;
|
||||
int16_t *samples = data;
|
||||
if(s->max_framesize == 0){
|
||||
void *tmp_ptr;
|
||||
s->max_framesize= 1024; // should hopefully be enough for the first header
|
||||
s->bitstream= av_fast_realloc(s->bitstream, &s->allocated_bitstream_size, s->max_framesize);
|
||||
tmp_ptr = av_fast_realloc(s->bitstream, &s->allocated_bitstream_size,
|
||||
s->max_framesize);
|
||||
if (!tmp_ptr) {
|
||||
av_log(avctx, AV_LOG_ERROR, "error allocating bitstream buffer\n");
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
s->bitstream = tmp_ptr;
|
||||
}
|
||||
|
||||
if(1 && s->max_framesize){//FIXME truncated
|
||||
@@ -514,8 +531,8 @@ static av_cold int shorten_decode_close(AVCodecContext *avctx)
|
||||
int i;
|
||||
|
||||
for (i = 0; i < s->channels; i++) {
|
||||
s->decoded[i] -= s->nwrap;
|
||||
av_freep(&s->decoded[i]);
|
||||
s->decoded[i] = NULL;
|
||||
av_freep(&s->decoded_base[i]);
|
||||
av_freep(&s->offset[i]);
|
||||
}
|
||||
av_freep(&s->bitstream);
|
||||
|
@@ -304,6 +304,10 @@ static int encode_frame(AVCodecContext * avctx, unsigned char *buf,
|
||||
|
||||
strip_sizes = av_mallocz(sizeof(*strip_sizes) * strips);
|
||||
strip_offsets = av_mallocz(sizeof(*strip_offsets) * strips);
|
||||
if (!strip_sizes || !strip_offsets) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
bytes_per_row = (((s->width - 1)/s->subsampling[0] + 1) * s->bpp
|
||||
* s->subsampling[0] * s->subsampling[1] + 7) >> 3;
|
||||
@@ -311,6 +315,7 @@ static int encode_frame(AVCodecContext * avctx, unsigned char *buf,
|
||||
yuv_line = av_malloc(bytes_per_row);
|
||||
if (yuv_line == NULL){
|
||||
av_log(s->avctx, AV_LOG_ERROR, "Not enough memory\n");
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
@@ -323,6 +328,10 @@ static int encode_frame(AVCodecContext * avctx, unsigned char *buf,
|
||||
|
||||
zlen = bytes_per_row * s->rps;
|
||||
zbuf = av_malloc(zlen);
|
||||
if (!zbuf) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
strip_offsets[0] = ptr - buf;
|
||||
zn = 0;
|
||||
for (j = 0; j < s->rps; j++) {
|
||||
@@ -347,8 +356,13 @@ static int encode_frame(AVCodecContext * avctx, unsigned char *buf,
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
if(s->compr == TIFF_LZW)
|
||||
if (s->compr == TIFF_LZW) {
|
||||
s->lzws = av_malloc(ff_lzw_encode_state_size);
|
||||
if (!s->lzws) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < s->height; i++) {
|
||||
if (strip_sizes[i / s->rps] == 0) {
|
||||
if(s->compr == TIFF_LZW){
|
||||
|
@@ -519,6 +519,10 @@ hres,vres,i,i%vres (0 < i < 4)
|
||||
}
|
||||
|
||||
#define APPLY_C_PREDICTOR() \
|
||||
if(index > 1023){\
|
||||
av_log(s->avctx, AV_LOG_ERROR, " index %d went out of bounds\n", index); \
|
||||
return; \
|
||||
}\
|
||||
predictor_pair = s->c_predictor_table[index]; \
|
||||
horiz_pred += (predictor_pair >> 1); \
|
||||
if (predictor_pair & 1) { \
|
||||
@@ -536,6 +540,10 @@ hres,vres,i,i%vres (0 < i < 4)
|
||||
index++;
|
||||
|
||||
#define APPLY_C_PREDICTOR_24() \
|
||||
if(index > 1023){\
|
||||
av_log(s->avctx, AV_LOG_ERROR, " index %d went out of bounds\n", index); \
|
||||
return; \
|
||||
}\
|
||||
predictor_pair = s->c_predictor_table[index]; \
|
||||
horiz_pred += (predictor_pair >> 1); \
|
||||
if (predictor_pair & 1) { \
|
||||
@@ -554,6 +562,10 @@ hres,vres,i,i%vres (0 < i < 4)
|
||||
|
||||
|
||||
#define APPLY_Y_PREDICTOR() \
|
||||
if(index > 1023){\
|
||||
av_log(s->avctx, AV_LOG_ERROR, " index %d went out of bounds\n", index); \
|
||||
return; \
|
||||
}\
|
||||
predictor_pair = s->y_predictor_table[index]; \
|
||||
horiz_pred += (predictor_pair >> 1); \
|
||||
if (predictor_pair & 1) { \
|
||||
@@ -571,6 +583,10 @@ hres,vres,i,i%vres (0 < i < 4)
|
||||
index++;
|
||||
|
||||
#define APPLY_Y_PREDICTOR_24() \
|
||||
if(index > 1023){\
|
||||
av_log(s->avctx, AV_LOG_ERROR, " index %d went out of bounds\n", index); \
|
||||
return; \
|
||||
}\
|
||||
predictor_pair = s->y_predictor_table[index]; \
|
||||
horiz_pred += (predictor_pair >> 1); \
|
||||
if (predictor_pair & 1) { \
|
||||
|
@@ -4347,6 +4347,7 @@ AVCodec vc1_decoder = {
|
||||
vc1_decode_frame,
|
||||
CODEC_CAP_DELAY,
|
||||
NULL,
|
||||
.flush = ff_mpeg_flush,
|
||||
.long_name = NULL_IF_CONFIG_SMALL("SMPTE VC-1"),
|
||||
.pix_fmts = ff_pixfmt_list_420
|
||||
};
|
||||
@@ -4362,6 +4363,7 @@ AVCodec wmv3_decoder = {
|
||||
vc1_decode_frame,
|
||||
CODEC_CAP_DELAY,
|
||||
NULL,
|
||||
.flush = ff_mpeg_flush,
|
||||
.long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 9"),
|
||||
.pix_fmts = ff_pixfmt_list_420
|
||||
};
|
||||
|
@@ -516,8 +516,14 @@ int vp56_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
|
||||
s->modelp = &s->models[is_alpha];
|
||||
|
||||
res = s->parse_header(s, buf, remaining_buf_size, &golden_frame);
|
||||
if (!res)
|
||||
return -1;
|
||||
if (!res) {
|
||||
int i;
|
||||
for (i = 0; i < 4; i++) {
|
||||
if (s->frames[i].data[0])
|
||||
avctx->release_buffer(avctx, &s->frames[i]);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
if (res == 2) {
|
||||
int i;
|
||||
|
@@ -61,8 +61,8 @@ static int vp6_parse_header(VP56Context *s, const uint8_t *buf, int buf_size,
|
||||
return 0;
|
||||
s->filter_header = buf[1] & 0x06;
|
||||
if (buf[1] & 1) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "interlacing not supported\n");
|
||||
return 0;
|
||||
av_log(s->avctx, AV_LOG_WARNING, "interlacing not supported\n");
|
||||
return AVERROR_PATCHWELCOME;
|
||||
}
|
||||
if (separated_coeff || !s->filter_header) {
|
||||
coeff_offset = AV_RB16(buf+2) - 2;
|
||||
|
@@ -526,6 +526,11 @@ static void vqa_decode_chunk(VqaContext *s)
|
||||
chunk_size = AV_RB32(&s->buf[cbp0_chunk + 4]);
|
||||
cbp0_chunk += CHUNK_PREAMBLE_SIZE;
|
||||
|
||||
if (chunk_size > MAX_CODEBOOK_SIZE - s->next_codebook_buffer_index) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "cbp0 chunk too large (0x%X bytes)\n", chunk_size);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
/* accumulate partial codebook */
|
||||
memcpy(&s->next_codebook_buffer[s->next_codebook_buffer_index],
|
||||
&s->buf[cbp0_chunk], chunk_size);
|
||||
@@ -549,6 +554,11 @@ static void vqa_decode_chunk(VqaContext *s)
|
||||
chunk_size = AV_RB32(&s->buf[cbpz_chunk + 4]);
|
||||
cbpz_chunk += CHUNK_PREAMBLE_SIZE;
|
||||
|
||||
if (chunk_size > MAX_CODEBOOK_SIZE - s->next_codebook_buffer_index) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "cbpz chunk too large (0x%X bytes)\n", chunk_size);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
/* accumulate partial codebook */
|
||||
memcpy(&s->next_codebook_buffer[s->next_codebook_buffer_index],
|
||||
&s->buf[cbpz_chunk], chunk_size);
|
||||
|
@@ -67,6 +67,11 @@ 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);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
rbuf = av_malloc(buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
if(!rbuf){
|
||||
av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer\n");
|
||||
|
@@ -20,8 +20,8 @@
|
||||
*/
|
||||
|
||||
#include "libavformat/avformat.h"
|
||||
#include <vfw.h>
|
||||
#include <windows.h>
|
||||
#include <vfw.h>
|
||||
|
||||
//#define DEBUG_VFW
|
||||
|
||||
|
@@ -43,6 +43,12 @@ AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b)
|
||||
AVFilterFormats *ret;
|
||||
unsigned i, j, k = 0;
|
||||
|
||||
if (a == b)
|
||||
return a;
|
||||
|
||||
if (a == b)
|
||||
return a;
|
||||
|
||||
ret = av_mallocz(sizeof(AVFilterFormats));
|
||||
|
||||
/* merge list of formats */
|
||||
|
@@ -780,13 +780,13 @@ resync:
|
||||
else
|
||||
ast->frame_offset++;
|
||||
}
|
||||
ast->remaining -= size;
|
||||
ast->remaining -= err;
|
||||
if(!ast->remaining){
|
||||
avi->stream_index= -1;
|
||||
ast->packet_size= 0;
|
||||
}
|
||||
|
||||
return size;
|
||||
return 0;
|
||||
}
|
||||
|
||||
memset(d, -1, sizeof(int)*8);
|
||||
|
@@ -448,12 +448,17 @@ static int ea_read_packet(AVFormatContext *s,
|
||||
|
||||
while (!packet_read) {
|
||||
chunk_type = get_le32(pb);
|
||||
chunk_size = (ea->big_endian ? get_be32(pb) : get_le32(pb)) - 8;
|
||||
chunk_size = ea->big_endian ? get_be32(pb) : get_le32(pb);
|
||||
if (chunk_size <= 8)
|
||||
return AVERROR_INVALIDDATA;
|
||||
chunk_size -= 8;
|
||||
|
||||
switch (chunk_type) {
|
||||
/* audio data */
|
||||
case ISNh_TAG:
|
||||
/* header chunk also contains data; skip over the header portion*/
|
||||
if (chunk_size < 32)
|
||||
return AVERROR_INVALIDDATA;
|
||||
url_fskip(pb, 32);
|
||||
chunk_size -= 32;
|
||||
case ISNd_TAG:
|
||||
|
@@ -66,8 +66,7 @@ ogg_save (AVFormatContext * s)
|
||||
|
||||
for (i = 0; i < ogg->nstreams; i++){
|
||||
struct ogg_stream *os = ogg->streams + i;
|
||||
os->buf = av_malloc (os->bufsize);
|
||||
memset (os->buf, 0, os->bufsize);
|
||||
os->buf = av_mallocz (os->bufsize + FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
memcpy (os->buf, ost->streams[i].buf, os->bufpos);
|
||||
}
|
||||
|
||||
@@ -170,13 +169,18 @@ ogg_new_stream (AVFormatContext * s, uint32_t serial)
|
||||
AVStream *st;
|
||||
struct ogg_stream *os;
|
||||
|
||||
ogg->streams = av_realloc (ogg->streams,
|
||||
ogg->nstreams * sizeof (*ogg->streams));
|
||||
os = av_realloc (ogg->streams, ogg->nstreams * sizeof (*ogg->streams));
|
||||
|
||||
if (!os)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
ogg->streams = os;
|
||||
|
||||
memset (ogg->streams + idx, 0, sizeof (*ogg->streams));
|
||||
os = ogg->streams + idx;
|
||||
os->serial = serial;
|
||||
os->bufsize = DECODER_BUFFER_SIZE;
|
||||
os->buf = av_malloc(os->bufsize);
|
||||
os->buf = av_malloc(os->bufsize + FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
os->header = -1;
|
||||
|
||||
st = av_new_stream (s, idx);
|
||||
@@ -192,7 +196,7 @@ static int
|
||||
ogg_new_buf(struct ogg *ogg, int idx)
|
||||
{
|
||||
struct ogg_stream *os = ogg->streams + idx;
|
||||
uint8_t *nb = av_malloc(os->bufsize);
|
||||
uint8_t *nb = av_malloc(os->bufsize + FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
int size = os->bufpos - os->pstart;
|
||||
if(os->buf){
|
||||
memcpy(nb, os->buf + os->pstart, size);
|
||||
@@ -289,7 +293,9 @@ ogg_read_page (AVFormatContext * s, int *str)
|
||||
}
|
||||
|
||||
if (os->bufsize - os->bufpos < size){
|
||||
uint8_t *nb = av_malloc (os->bufsize *= 2);
|
||||
uint8_t *nb = av_malloc ((os->bufsize *= 2) + FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
if (!nb)
|
||||
return AVERROR(ENOMEM);
|
||||
memcpy (nb, os->buf, os->bufpos);
|
||||
av_free (os->buf);
|
||||
os->buf = nb;
|
||||
@@ -303,6 +309,7 @@ ogg_read_page (AVFormatContext * s, int *str)
|
||||
os->granule = gp;
|
||||
os->flags = flags;
|
||||
|
||||
memset(os->buf + os->bufpos, 0, FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
if (str)
|
||||
*str = idx;
|
||||
|
||||
|
@@ -496,8 +496,10 @@ static int swf_write_trailer(AVFormatContext *s)
|
||||
put_le32(pb, file_size);
|
||||
url_fseek(pb, swf->duration_pos, SEEK_SET);
|
||||
put_le16(pb, swf->video_frame_number);
|
||||
if (swf->vframes_pos) {
|
||||
url_fseek(pb, swf->vframes_pos, SEEK_SET);
|
||||
put_le16(pb, swf->video_frame_number);
|
||||
}
|
||||
url_fseek(pb, file_size, SEEK_SET);
|
||||
}
|
||||
return 0;
|
||||
|
@@ -680,7 +680,10 @@ static void compute_frame_duration(int *pnum, int *pden, AVStream *st,
|
||||
*pnum = st->codec->time_base.num;
|
||||
*pden = st->codec->time_base.den;
|
||||
if (pc && pc->repeat_pict) {
|
||||
*pnum = (*pnum) * (1 + pc->repeat_pict);
|
||||
if (*pnum > INT_MAX / (1 + pc->repeat_pict))
|
||||
*pden /= 1 + pc->repeat_pict;
|
||||
else
|
||||
*pnum *= 1 + pc->repeat_pict;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@@ -152,6 +152,11 @@ static int yuv4_write_header(AVFormatContext *s)
|
||||
if (s->nb_streams != 1)
|
||||
return AVERROR(EIO);
|
||||
|
||||
if (s->streams[0]->codec->codec_id != CODEC_ID_RAWVIDEO) {
|
||||
av_log(s, AV_LOG_ERROR, "ERROR: Only rawvideo supported.\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
if (s->streams[0]->codec->pix_fmt == PIX_FMT_YUV411P) {
|
||||
av_log(s, AV_LOG_ERROR, "Warning: generating rarely used 4:1:1 YUV stream, some mjpegtools might not work.\n");
|
||||
}
|
||||
@@ -340,7 +345,7 @@ static int yuv4_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
{
|
||||
int i;
|
||||
char header[MAX_FRAME_HEADER+1];
|
||||
int packet_size, width, height;
|
||||
int packet_size, width, height, ret;
|
||||
AVStream *st = s->streams[0];
|
||||
struct frame_attributes *s1 = s->priv_data;
|
||||
|
||||
@@ -351,18 +356,28 @@ static int yuv4_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == MAX_FRAME_HEADER) return -1;
|
||||
if (strncmp(header, Y4M_FRAME_MAGIC, strlen(Y4M_FRAME_MAGIC))) return -1;
|
||||
if (s->pb->error)
|
||||
return s->pb->error;
|
||||
else if (s->pb->eof_reached)
|
||||
return AVERROR_EOF;
|
||||
else if (i == MAX_FRAME_HEADER)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
if (strncmp(header, Y4M_FRAME_MAGIC, strlen(Y4M_FRAME_MAGIC)))
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
width = st->codec->width;
|
||||
height = st->codec->height;
|
||||
|
||||
packet_size = avpicture_get_size(st->codec->pix_fmt, width, height);
|
||||
if (packet_size < 0)
|
||||
return -1;
|
||||
return packet_size;
|
||||
|
||||
if (av_get_packet(s->pb, pkt, packet_size) != packet_size)
|
||||
return AVERROR(EIO);
|
||||
ret = av_get_packet(s->pb, pkt, packet_size);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
else if (ret != packet_size)
|
||||
return s->pb->eof_reached ? AVERROR_EOF : AVERROR(EIO);
|
||||
|
||||
if (s->streams[0]->codec->coded_frame) {
|
||||
s->streams[0]->codec->coded_frame->interlaced_frame = s1->interlaced_frame;
|
||||
|
Reference in New Issue
Block a user