Compare commits
92 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 | ||
![]() |
a55db1fc49 | ||
![]() |
123e925956 | ||
![]() |
96c6b3a11c | ||
![]() |
5e3cd42b6d | ||
![]() |
f73106256d | ||
![]() |
782c3ab777 | ||
![]() |
4b2e02a4c4 | ||
![]() |
79fbcd9f03 | ||
![]() |
468cc41d6d | ||
![]() |
6c9b404dba | ||
![]() |
b2ac7e585e | ||
![]() |
8bb3ba5541 | ||
![]() |
5a92aa378d | ||
![]() |
c4e8c99507 | ||
![]() |
479869c499 | ||
![]() |
ec4979e16e | ||
![]() |
056c909d9d | ||
![]() |
bde4b66063 | ||
![]() |
0fda37cff9 | ||
![]() |
2e693be7e9 | ||
![]() |
8e101086eb | ||
![]() |
f13de3c653 | ||
![]() |
1eb7872238 | ||
![]() |
15df4428d2 | ||
![]() |
ec0124203c | ||
![]() |
6b01bcebb9 | ||
![]() |
efd453d82d | ||
![]() |
7209c2b13f | ||
![]() |
7ee536e87a | ||
![]() |
665421f3b1 | ||
![]() |
3eb6983dbc |
72
Changelog
72
Changelog
@@ -1,6 +1,78 @@
|
||||
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:
|
||||
|
||||
- id3v2: fix skipping extended header in id3v2.4
|
||||
- nsvdec: Several bugfixes related to CVE-2011-3940
|
||||
- dv: check stype
|
||||
- dv: Fix null pointer dereference due to ach=0
|
||||
- dv: Fix small stack overread related to CVE-2011-3929 and CVE-2011-3936.
|
||||
- atrac3: Fix crash in tonal component decoding, fixes CVE-2012-0853
|
||||
- mjpegbdec: Fix overflow in SOS, fixes CVE-2011-3947
|
||||
- motionpixels: Clip YUV values after applying a gradient.
|
||||
- vqavideo: return error if image size is not a multiple of block size,
|
||||
fixes CVE-2012-0947.
|
||||
|
||||
|
||||
version 0.5.7:
|
||||
- vorbis: An additional defense in the Vorbis codec. (CVE-2011-3895)
|
||||
- vorbisdec: Fix decoding bug with channel handling.
|
||||
- matroskadec: Fix a bug where a pointer was cached to an array that might
|
||||
later move due to a realloc(). (CVE-2011-3893)
|
||||
- vorbis: Avoid some out-of-bounds reads. (CVE-2011-3893)
|
||||
- vp3: fix oob read for negative tokens and memleaks on error, (CVE-2011-3892)
|
||||
- vp3: fix streams with non-zero last coefficient.
|
||||
|
||||
|
||||
version 0.5.6:
|
||||
- svq1dec: call avcodec_set_dimensions() after dimensions changed. (NGS00148, CVE-2011-4579)
|
||||
|
72
RELEASE
72
RELEASE
@@ -180,3 +180,75 @@ release.
|
||||
|
||||
Distributors and system integrators are encouraged to update and share
|
||||
their patches against this branch.
|
||||
|
||||
|
||||
|
||||
* 0.5.8 Jan 12, 2012
|
||||
|
||||
General notes
|
||||
-------------
|
||||
|
||||
This mostly maintenance-only release that addresses a number a number of
|
||||
bugs such as security and compilation issues that have been brought to
|
||||
our attention. Among other (rather minor) fixes, this release features
|
||||
fixes for the VP3 decoder (CVE-2011-3892), vorbis decoder, and matroska
|
||||
demuxer (CVE-2011-3893 and CVE-2011-3895).
|
||||
|
||||
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
|
||||
-------------
|
||||
|
||||
This maintenance-only release that addresses a number a number of
|
||||
security issues that have been brought to our attention. Among other
|
||||
(rather minor) fixes, this release features fixes for the DV decoder
|
||||
(CVE-2011-3929 and CVE-2011-3936), nsvdec (CVE-2011-3940), Atrac3
|
||||
(CVE-2012-0853), mjpegdec (CVE-2011-3947) and the VQA video decoder
|
||||
(CVE-2012-0947).
|
||||
|
||||
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) {
|
||||
|
@@ -454,6 +454,8 @@ static int decodeTonalComponents (GetBitContext *gb, tonal_component *pComponent
|
||||
|
||||
for (k=0; k<coded_components; k++) {
|
||||
sfIndx = get_bits(gb,6);
|
||||
if(component_count>=64)
|
||||
return AVERROR_INVALIDDATA;
|
||||
pComponent[component_count].pos = j * 64 + (get_bits(gb,6));
|
||||
max_coded_values = 1024 - pComponent[component_count].pos;
|
||||
coded_values = coded_values_per_component + 1;
|
||||
|
@@ -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);
|
||||
|
@@ -285,6 +285,10 @@ static int h261_decode_mb(H261Context *h){
|
||||
|
||||
// Read mtype
|
||||
h->mtype = get_vlc2(&s->gb, h261_mtype_vlc.table, H261_MTYPE_VLC_BITS, 2);
|
||||
if (h->mtype < 0) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "illegal mtype %d\n", h->mtype);
|
||||
return SLICE_ERROR;
|
||||
}
|
||||
h->mtype = h261_mtype_map[h->mtype];
|
||||
|
||||
// Read mquant
|
||||
|
@@ -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
|
||||
|
@@ -49,6 +49,9 @@ read_header:
|
||||
s->restart_count = 0;
|
||||
s->mjpb_skiptosod = 0;
|
||||
|
||||
if (buf_end - buf_ptr >= 1 << 28)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
init_get_bits(&hgb, buf_ptr, /*buf_size*/(buf_end - buf_ptr)*8);
|
||||
|
||||
skip_bits(&hgb, 32); /* reserved zeros */
|
||||
@@ -99,8 +102,8 @@ read_header:
|
||||
av_log(avctx, AV_LOG_DEBUG, "sod offs: 0x%x\n", sod_offs);
|
||||
if (sos_offs)
|
||||
{
|
||||
// init_get_bits(&s->gb, buf+sos_offs, (buf_end - (buf+sos_offs))*8);
|
||||
init_get_bits(&s->gb, buf_ptr+sos_offs, field_size*8);
|
||||
init_get_bits(&s->gb, buf_ptr + sos_offs,
|
||||
8 * FFMIN(field_size, buf_end - buf_ptr - sos_offs));
|
||||
s->mjpb_skiptosod = (sod_offs - sos_offs - show_bits(&s->gb, 16));
|
||||
s->start_code = SOS;
|
||||
ff_mjpeg_decode_sos(s);
|
||||
|
@@ -239,10 +239,13 @@ static void mp_decode_line(MotionPixelsContext *mp, GetBitContext *gb, int y)
|
||||
p = mp_get_yuv_from_rgb(mp, x - 1, y);
|
||||
} else {
|
||||
p.y += mp_gradient(mp, 0, mp_get_vlc(mp, gb));
|
||||
p.y = av_clip(p.y, 0, 31);
|
||||
if ((x & 3) == 0) {
|
||||
if ((y & 3) == 0) {
|
||||
p.v += mp_gradient(mp, 1, mp_get_vlc(mp, gb));
|
||||
p.v = av_clip(p.v, -32, 31);
|
||||
p.u += mp_gradient(mp, 2, mp_get_vlc(mp, gb));
|
||||
p.u = av_clip(p.u, -32, 31);
|
||||
mp->hpt[((y / 4) * mp->avctx->width + x) / 4] = p;
|
||||
} else {
|
||||
p.v = mp->hpt[((y / 4) * mp->avctx->width + x) / 4].v;
|
||||
@@ -266,9 +269,12 @@ static void mp_decode_frame_helper(MotionPixelsContext *mp, GetBitContext *gb)
|
||||
p = mp_get_yuv_from_rgb(mp, 0, y);
|
||||
} else {
|
||||
p.y += mp_gradient(mp, 0, mp_get_vlc(mp, gb));
|
||||
p.y = av_clip(p.y, 0, 31);
|
||||
if ((y & 3) == 0) {
|
||||
p.v += mp_gradient(mp, 1, mp_get_vlc(mp, gb));
|
||||
p.v = av_clip(p.v, -32, 31);
|
||||
p.u += mp_gradient(mp, 2, mp_get_vlc(mp, gb));
|
||||
p.u = av_clip(p.u, -32, 31);
|
||||
}
|
||||
mp->vpt[y] = p;
|
||||
mp_set_rgb_from_yuv(mp, 0, y, &p);
|
||||
|
@@ -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
|
||||
};
|
||||
|
@@ -146,13 +146,13 @@ void ff_vorbis_ready_floor1_list(vorbis_floor1_entry * list, int values) {
|
||||
}
|
||||
}
|
||||
|
||||
static void render_line(int x0, int y0, int x1, int y1, float * buf) {
|
||||
static void render_line(int x0, uint8_t y0, int x1, int y1, float * buf) {
|
||||
int dy = y1 - y0;
|
||||
int adx = x1 - x0;
|
||||
int base = dy / adx;
|
||||
int ady = FFABS(dy) - FFABS(base) * adx;
|
||||
int x = x0;
|
||||
int y = y0;
|
||||
uint8_t y = y0;
|
||||
int err = 0;
|
||||
int sy = dy<0 ? -1 : 1;
|
||||
buf[x] = ff_vorbis_floor1_inverse_db_table[y];
|
||||
@@ -168,7 +168,8 @@ static void render_line(int x0, int y0, int x1, int y1, float * buf) {
|
||||
}
|
||||
|
||||
void ff_vorbis_floor1_render_list(vorbis_floor1_entry * list, int values, uint_fast16_t * y_list, int * flag, int multiplier, float * out, int samples) {
|
||||
int lx, ly, i;
|
||||
int lx, i;
|
||||
uint8_t ly;
|
||||
lx = 0;
|
||||
ly = y_list[0] * multiplier;
|
||||
for (i = 1; i < values; i++) {
|
||||
|
@@ -654,7 +654,7 @@ static int vorbis_parse_setup_hdr_residues(vorbis_context *vc){
|
||||
res_setup->partition_size=get_bits(gb, 24)+1;
|
||||
/* Validations to prevent a buffer overflow later. */
|
||||
if (res_setup->begin>res_setup->end
|
||||
|| res_setup->end>vc->blocksize[1]/(res_setup->type==2?1:2)
|
||||
|| res_setup->end > (res_setup->type == 2 ? vc->avccontext->channels : 1) * vc->blocksize[1] / 2
|
||||
|| (res_setup->end-res_setup->begin)/res_setup->partition_size>V_MAX_PARTITIONS) {
|
||||
av_log(vc->avccontext, AV_LOG_ERROR, "partition out of bounds: type, begin, end, size, blocksize: %d, %d, %d, %d, %d\n", res_setup->type, res_setup->begin, res_setup->end, res_setup->partition_size, vc->blocksize[1]/2);
|
||||
return 1;
|
||||
@@ -1293,7 +1293,7 @@ static int vorbis_floor1_decode(vorbis_context *vc, vorbis_floor_data *vfu, floa
|
||||
|
||||
// Read and decode residue
|
||||
|
||||
static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc, vorbis_residue *vr, uint_fast8_t ch, uint_fast8_t *do_not_decode, float *vec, uint_fast16_t vlen, int vr_type) {
|
||||
static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc, vorbis_residue *vr, uint_fast8_t ch, uint_fast8_t *do_not_decode, float *vec, uint_fast16_t vlen, unsigned ch_left, int vr_type) {
|
||||
GetBitContext *gb=&vc->gb;
|
||||
uint_fast8_t c_p_c=vc->codebooks[vr->classbook].dimensions;
|
||||
uint_fast16_t n_to_read=vr->end-vr->begin;
|
||||
@@ -1303,6 +1303,7 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc, v
|
||||
uint_fast8_t ch_used;
|
||||
uint_fast8_t i,j,l;
|
||||
uint_fast16_t k;
|
||||
unsigned max_output = (ch - 1) * vlen;
|
||||
|
||||
if (vr_type==2) {
|
||||
for(j=1;j<ch;++j) {
|
||||
@@ -1310,8 +1311,15 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc, v
|
||||
}
|
||||
if (do_not_decode[0]) return 0;
|
||||
ch_used=1;
|
||||
max_output += vr->end / ch;
|
||||
} else {
|
||||
ch_used=ch;
|
||||
max_output += vr->end;
|
||||
}
|
||||
|
||||
if (max_output > ch_left * vlen) {
|
||||
av_log(vc->avccontext, AV_LOG_ERROR, "Insufficient output buffer\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
AV_DEBUG(" residue type 0/1/2 decode begin, ch: %d cpc %d \n", ch, c_p_c);
|
||||
@@ -1435,14 +1443,14 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc, v
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int vorbis_residue_decode(vorbis_context *vc, vorbis_residue *vr, uint_fast8_t ch, uint_fast8_t *do_not_decode, float *vec, uint_fast16_t vlen)
|
||||
static inline int vorbis_residue_decode(vorbis_context *vc, vorbis_residue *vr, uint_fast8_t ch, uint_fast8_t *do_not_decode, float *vec, uint_fast16_t vlen, unsigned ch_left)
|
||||
{
|
||||
if (vr->type==2)
|
||||
return vorbis_residue_decode_internal(vc, vr, ch, do_not_decode, vec, vlen, 2);
|
||||
else if (vr->type==1)
|
||||
return vorbis_residue_decode_internal(vc, vr, ch, do_not_decode, vec, vlen, 1);
|
||||
else if (vr->type==0)
|
||||
return vorbis_residue_decode_internal(vc, vr, ch, do_not_decode, vec, vlen, 0);
|
||||
return vorbis_residue_decode_internal(vc, vr, ch, do_not_decode, vec, vlen, ch_left, 2);
|
||||
else if (vr->type == 1)
|
||||
return vorbis_residue_decode_internal(vc, vr, ch, do_not_decode, vec, vlen, ch_left, 1);
|
||||
else if (vr->type == 0)
|
||||
return vorbis_residue_decode_internal(vc, vr, ch, do_not_decode, vec, vlen, ch_left, 0);
|
||||
else {
|
||||
av_log(vc->avccontext, AV_LOG_ERROR, " Invalid residue type while residue decode?! \n");
|
||||
return 1;
|
||||
@@ -1505,6 +1513,8 @@ static int vorbis_parse_audio_packet(vorbis_context *vc) {
|
||||
uint_fast8_t res_num=0;
|
||||
int_fast16_t retlen=0;
|
||||
float fadd_bias = vc->add_bias;
|
||||
unsigned ch_left = vc->audio_channels;
|
||||
unsigned vlen;
|
||||
|
||||
if (get_bits1(gb)) {
|
||||
av_log(vc->avccontext, AV_LOG_ERROR, "Not a Vorbis I audio packet.\n");
|
||||
@@ -1527,12 +1537,13 @@ static int vorbis_parse_audio_packet(vorbis_context *vc) {
|
||||
|
||||
blockflag=vc->modes[mode_number].blockflag;
|
||||
blocksize=vc->blocksize[blockflag];
|
||||
vlen = blocksize / 2;
|
||||
if (blockflag) {
|
||||
skip_bits(gb, 2); // previous_window, next_window
|
||||
}
|
||||
|
||||
memset(ch_res_ptr, 0, sizeof(float)*vc->audio_channels*blocksize/2); //FIXME can this be removed ?
|
||||
memset(ch_floor_ptr, 0, sizeof(float)*vc->audio_channels*blocksize/2); //FIXME can this be removed ?
|
||||
memset(ch_res_ptr, 0, sizeof(float)*vc->audio_channels*vlen); //FIXME can this be removed ?
|
||||
memset(ch_floor_ptr, 0, sizeof(float)*vc->audio_channels*vlen); //FIXME can this be removed ?
|
||||
|
||||
// Decode floor
|
||||
|
||||
@@ -1552,7 +1563,7 @@ static int vorbis_parse_audio_packet(vorbis_context *vc) {
|
||||
return -1;
|
||||
}
|
||||
no_residue[i] = ret;
|
||||
ch_floor_ptr += blocksize / 2;
|
||||
ch_floor_ptr += vlen;
|
||||
}
|
||||
|
||||
// Nonzero vector propagate
|
||||
@@ -1569,6 +1580,7 @@ static int vorbis_parse_audio_packet(vorbis_context *vc) {
|
||||
for(i=0;i<mapping->submaps;++i) {
|
||||
vorbis_residue *residue;
|
||||
uint_fast8_t ch=0;
|
||||
int ret;
|
||||
|
||||
for(j=0;j<vc->audio_channels;++j) {
|
||||
if ((mapping->submaps==1) || (i==mapping->mux[j])) {
|
||||
@@ -1583,9 +1595,18 @@ static int vorbis_parse_audio_packet(vorbis_context *vc) {
|
||||
}
|
||||
}
|
||||
residue=&vc->residues[mapping->submap_residue[i]];
|
||||
vorbis_residue_decode(vc, residue, ch, do_not_decode, ch_res_ptr, blocksize/2);
|
||||
if (ch_left < ch) {
|
||||
av_log(vc->avccontext, AV_LOG_ERROR, "Too many channels in vorbis_floor_decode.\n");
|
||||
return -1;
|
||||
}
|
||||
if (ch) {
|
||||
ret = vorbis_residue_decode(vc, residue, ch, do_not_decode, ch_res_ptr, vlen, ch_left);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
ch_res_ptr+=ch*blocksize/2;
|
||||
ch_res_ptr += ch * vlen;
|
||||
ch_left -= ch;
|
||||
}
|
||||
|
||||
// Inverse coupling
|
||||
|
@@ -1011,12 +1011,12 @@ static int unpack_vlcs(Vp3DecodeContext *s, GetBitContext *gb,
|
||||
/* decode a VLC into a token */
|
||||
token = get_vlc2(gb, table->table, 5, 3);
|
||||
/* use the token to get a zero run, a coefficient, and an eob run */
|
||||
if (token <= 6) {
|
||||
if ((unsigned) token <= 6U) {
|
||||
eob_run = eob_run_base[token];
|
||||
if (eob_run_get_bits[token])
|
||||
eob_run += get_bits(gb, eob_run_get_bits[token]);
|
||||
coeff = zero_run = 0;
|
||||
} else {
|
||||
} else if (token >= 0) {
|
||||
bits_to_get = coeff_get_bits[token];
|
||||
if (!bits_to_get)
|
||||
coeff = coeff_tables[token][0];
|
||||
@@ -1026,6 +1026,10 @@ static int unpack_vlcs(Vp3DecodeContext *s, GetBitContext *gb,
|
||||
zero_run = zero_run_base[token];
|
||||
if (zero_run_get_bits[token])
|
||||
zero_run += get_bits(gb, zero_run_get_bits[token]);
|
||||
} else {
|
||||
av_log(s->avctx, AV_LOG_ERROR,
|
||||
"Invalid token %d\n", token);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1071,6 +1075,8 @@ static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBitContext *gb)
|
||||
/* unpack the C plane DC coefficients */
|
||||
residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_c_table], 0,
|
||||
s->first_coded_c_fragment, s->last_coded_c_fragment, residual_eob_run);
|
||||
if (residual_eob_run < 0)
|
||||
return residual_eob_run;
|
||||
|
||||
/* fetch the AC table indexes */
|
||||
ac_y_table = get_bits(gb, 4);
|
||||
@@ -1080,36 +1086,52 @@ static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBitContext *gb)
|
||||
for (i = 1; i <= 5; i++) {
|
||||
residual_eob_run = unpack_vlcs(s, gb, &s->ac_vlc_1[ac_y_table], i,
|
||||
s->first_coded_y_fragment, s->last_coded_y_fragment, residual_eob_run);
|
||||
if (residual_eob_run < 0)
|
||||
return residual_eob_run;
|
||||
|
||||
residual_eob_run = unpack_vlcs(s, gb, &s->ac_vlc_1[ac_c_table], i,
|
||||
s->first_coded_c_fragment, s->last_coded_c_fragment, residual_eob_run);
|
||||
if (residual_eob_run < 0)
|
||||
return residual_eob_run;
|
||||
}
|
||||
|
||||
/* unpack the group 2 AC coefficients (coeffs 6-14) */
|
||||
for (i = 6; i <= 14; i++) {
|
||||
residual_eob_run = unpack_vlcs(s, gb, &s->ac_vlc_2[ac_y_table], i,
|
||||
s->first_coded_y_fragment, s->last_coded_y_fragment, residual_eob_run);
|
||||
if (residual_eob_run < 0)
|
||||
return residual_eob_run;
|
||||
|
||||
residual_eob_run = unpack_vlcs(s, gb, &s->ac_vlc_2[ac_c_table], i,
|
||||
s->first_coded_c_fragment, s->last_coded_c_fragment, residual_eob_run);
|
||||
if (residual_eob_run < 0)
|
||||
return residual_eob_run;
|
||||
}
|
||||
|
||||
/* unpack the group 3 AC coefficients (coeffs 15-27) */
|
||||
for (i = 15; i <= 27; i++) {
|
||||
residual_eob_run = unpack_vlcs(s, gb, &s->ac_vlc_3[ac_y_table], i,
|
||||
s->first_coded_y_fragment, s->last_coded_y_fragment, residual_eob_run);
|
||||
if (residual_eob_run < 0)
|
||||
return residual_eob_run;
|
||||
|
||||
residual_eob_run = unpack_vlcs(s, gb, &s->ac_vlc_3[ac_c_table], i,
|
||||
s->first_coded_c_fragment, s->last_coded_c_fragment, residual_eob_run);
|
||||
if (residual_eob_run < 0)
|
||||
return residual_eob_run;
|
||||
}
|
||||
|
||||
/* unpack the group 4 AC coefficients (coeffs 28-63) */
|
||||
for (i = 28; i <= 63; i++) {
|
||||
residual_eob_run = unpack_vlcs(s, gb, &s->ac_vlc_4[ac_y_table], i,
|
||||
s->first_coded_y_fragment, s->last_coded_y_fragment, residual_eob_run);
|
||||
if (residual_eob_run < 0)
|
||||
return residual_eob_run;
|
||||
|
||||
residual_eob_run = unpack_vlcs(s, gb, &s->ac_vlc_4[ac_c_table], i,
|
||||
s->first_coded_c_fragment, s->last_coded_c_fragment, residual_eob_run);
|
||||
if (residual_eob_run < 0)
|
||||
return residual_eob_run;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@@ -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;
|
||||
|
@@ -163,6 +163,12 @@ static av_cold int vqa_decode_init(AVCodecContext *avctx)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (s->width & (s->vector_width - 1) ||
|
||||
s->height & (s->vector_height - 1)) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Image size not multiple of block size\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
/* allocate codebooks */
|
||||
s->codebook_size = MAX_CODEBOOK_SIZE;
|
||||
s->codebook = av_malloc(s->codebook_size);
|
||||
@@ -520,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);
|
||||
@@ -543,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");
|
||||
|
@@ -882,6 +882,7 @@ static int vsad16_mmx2(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, i
|
||||
|
||||
static void diff_bytes_mmx(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w){
|
||||
x86_reg i=0;
|
||||
if(w>=16)
|
||||
__asm__ volatile(
|
||||
"1: \n\t"
|
||||
"movq (%2, %0), %%mm0 \n\t"
|
||||
|
@@ -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 */
|
||||
|
@@ -127,6 +127,10 @@ static int fourxm_read_header(AVFormatContext *s,
|
||||
for (i = 0; i < header_size - 8; i++) {
|
||||
fourcc_tag = AV_RL32(&header[i]);
|
||||
size = AV_RL32(&header[i + 4]);
|
||||
if (size > header_size - i - 8 && (fourcc_tag == vtrk_TAG || fourcc_tag == strk_TAG)) {
|
||||
av_log(s, AV_LOG_ERROR, "chunk larger than array %d>%d\n", size, header_size - i - 8);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
if (fourcc_tag == std__TAG) {
|
||||
fourxm->fps = av_int2flt(AV_RL32(&header[i + 12]));
|
||||
|
@@ -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);
|
||||
|
@@ -125,10 +125,14 @@ static int dv_extract_audio(uint8_t* frame, uint8_t* ppcm[4],
|
||||
/* We work with 720p frames split in half, thus even frames have
|
||||
* channels 0,1 and odd 2,3. */
|
||||
ipcm = (sys->height == 720 && !(frame[1] & 0x0C)) ? 2 : 0;
|
||||
pcm = ppcm[ipcm++];
|
||||
|
||||
/* for each DIF channel */
|
||||
for (chan = 0; chan < sys->n_difchan; chan++) {
|
||||
/* next stereo channel (50Mbps and 100Mbps only) */
|
||||
pcm = ppcm[ipcm++];
|
||||
if (!pcm)
|
||||
break;
|
||||
|
||||
/* for each DIF segment */
|
||||
for (i = 0; i < sys->difseg_size; i++) {
|
||||
frame += 6 * 80; /* skip DIF segment header */
|
||||
@@ -176,11 +180,6 @@ static int dv_extract_audio(uint8_t* frame, uint8_t* ppcm[4],
|
||||
frame += 16 * 80; /* 15 Video DIFs + 1 Audio DIF */
|
||||
}
|
||||
}
|
||||
|
||||
/* next stereo channel (50Mbps and 100Mbps only) */
|
||||
pcm = ppcm[ipcm++];
|
||||
if (!pcm)
|
||||
break;
|
||||
}
|
||||
|
||||
return size;
|
||||
@@ -202,6 +201,12 @@ static int dv_extract_audio_info(DVDemuxContext* c, uint8_t* frame)
|
||||
stype = (as_pack[3] & 0x1f); /* 0 - 2CH, 2 - 4CH, 3 - 8CH */
|
||||
quant = as_pack[4] & 0x07; /* 0 - 16bit linear, 1 - 12bit nonlinear */
|
||||
|
||||
if (stype > 3) {
|
||||
av_log(c->fctx, AV_LOG_ERROR, "stype %d is invalid\n", stype);
|
||||
c->ach = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* note: ach counts PAIRS of channels (i.e. stereo channels) */
|
||||
ach = ((int[4]){ 1, 0, 2, 4})[stype];
|
||||
if (ach == 1 && quant && freq == 2)
|
||||
@@ -335,7 +340,8 @@ int dv_produce_packet(DVDemuxContext *c, AVPacket *pkt,
|
||||
c->audio_pkt[i].pts = c->abytes * 30000*8 / c->ast[i]->codec->bit_rate;
|
||||
ppcm[i] = c->audio_buf[i];
|
||||
}
|
||||
dv_extract_audio(buf, ppcm, c->sys);
|
||||
if (c->ach)
|
||||
dv_extract_audio(buf, ppcm, c->sys);
|
||||
c->abytes += size;
|
||||
|
||||
/* We work with 720p frames split in half, thus even frames have
|
||||
|
@@ -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:
|
||||
|
@@ -1063,13 +1063,13 @@ static void matroska_convert_tags(AVFormatContext *s)
|
||||
static void matroska_execute_seekhead(MatroskaDemuxContext *matroska)
|
||||
{
|
||||
EbmlList *seekhead_list = &matroska->seekhead;
|
||||
MatroskaSeekhead *seekhead = seekhead_list->elem;
|
||||
uint32_t level_up = matroska->level_up;
|
||||
int64_t before_pos = url_ftell(matroska->ctx->pb);
|
||||
MatroskaLevel level;
|
||||
int i;
|
||||
|
||||
for (i=0; i<seekhead_list->nb_elem; i++) {
|
||||
MatroskaSeekhead *seekhead = seekhead_list->elem;
|
||||
int64_t offset = seekhead[i].pos + matroska->segment_start;
|
||||
|
||||
if (seekhead[i].pos <= before_pos
|
||||
|
@@ -162,7 +162,6 @@ static int mm_read_packet(AVFormatContext *s,
|
||||
case MM_TYPE_AUDIO :
|
||||
if (av_get_packet(s->pb, pkt, length)<0)
|
||||
return AVERROR(ENOMEM);
|
||||
pkt->size = length;
|
||||
pkt->stream_index = 1;
|
||||
pkt->pts = mm->audio_pts++;
|
||||
return 0;
|
||||
|
@@ -246,8 +246,17 @@ static void id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t fl
|
||||
goto error;
|
||||
}
|
||||
|
||||
if(isv34 && flags & 0x40) /* Extended header present, just skip over it */
|
||||
url_fskip(s->pb, id3v2_get_size(s->pb, 4));
|
||||
if (isv34 && flags & 0x40) { /* Extended header present, just skip over it */
|
||||
int extlen = id3v2_get_size(s->pb, 4);
|
||||
if (version == 4)
|
||||
extlen -= 4; // in v2.4 the length includes the length field we just read
|
||||
|
||||
if (extlen < 0) {
|
||||
reason = "invalid extended header length";
|
||||
goto error;
|
||||
}
|
||||
url_fskip(s->pb, extlen);
|
||||
}
|
||||
|
||||
while(len >= taghdrlen) {
|
||||
if(isv34) {
|
||||
|
@@ -317,7 +317,9 @@ static int nsv_parse_NSVf_header(AVFormatContext *s, AVFormatParameters *ap)
|
||||
char *token, *value;
|
||||
char quote;
|
||||
|
||||
p = strings = av_mallocz(strings_size + 1);
|
||||
p = strings = av_mallocz((size_t)strings_size + 1);
|
||||
if (!p)
|
||||
return AVERROR(ENOMEM);
|
||||
endp = strings + strings_size;
|
||||
get_buffer(pb, strings, strings_size);
|
||||
while (p < endp) {
|
||||
@@ -351,6 +353,8 @@ static int nsv_parse_NSVf_header(AVFormatContext *s, AVFormatParameters *ap)
|
||||
if((unsigned)table_entries >= UINT_MAX / sizeof(uint32_t))
|
||||
return -1;
|
||||
nsv->nsvf_index_data = av_malloc(table_entries * sizeof(uint32_t));
|
||||
if (!nsv->nsvf_index_data)
|
||||
return AVERROR(ENOMEM);
|
||||
#warning "FIXME: Byteswap buffer as needed"
|
||||
get_buffer(pb, (unsigned char *)nsv->nsvf_index_data, table_entries * sizeof(uint32_t));
|
||||
}
|
||||
@@ -507,11 +511,16 @@ static int nsv_read_header(AVFormatContext *s, AVFormatParameters *ap)
|
||||
for (i = 0; i < NSV_MAX_RESYNC_TRIES; i++) {
|
||||
if (nsv_resync(s) < 0)
|
||||
return -1;
|
||||
if (nsv->state == NSV_FOUND_NSVF)
|
||||
if (nsv->state == NSV_FOUND_NSVF) {
|
||||
err = nsv_parse_NSVf_header(s, ap);
|
||||
if (err < 0)
|
||||
return err;
|
||||
}
|
||||
/* we need the first NSVs also... */
|
||||
if (nsv->state == NSV_FOUND_NSVS) {
|
||||
err = nsv_parse_NSVs_header(s, ap);
|
||||
if (err < 0)
|
||||
return err;
|
||||
break; /* we just want the first one */
|
||||
}
|
||||
}
|
||||
@@ -586,12 +595,12 @@ null_chunk_retry:
|
||||
}
|
||||
|
||||
/* map back streams to v,a */
|
||||
if (s->streams[0])
|
||||
if (s->nb_streams > 0)
|
||||
st[s->streams[0]->id] = s->streams[0];
|
||||
if (s->streams[1])
|
||||
if (s->nb_streams > 1)
|
||||
st[s->streams[1]->id] = s->streams[1];
|
||||
|
||||
if (vsize/* && st[NSV_ST_VIDEO]*/) {
|
||||
if (vsize && st[NSV_ST_VIDEO]) {
|
||||
nst = st[NSV_ST_VIDEO]->priv_data;
|
||||
pkt = &nsv->ahead[NSV_ST_VIDEO];
|
||||
av_get_packet(pb, pkt, vsize);
|
||||
@@ -606,7 +615,7 @@ null_chunk_retry:
|
||||
if(st[NSV_ST_VIDEO])
|
||||
((NSVStream*)st[NSV_ST_VIDEO]->priv_data)->frame_offset++;
|
||||
|
||||
if (asize/*st[NSV_ST_AUDIO]*/) {
|
||||
if (asize && st[NSV_ST_AUDIO]) {
|
||||
nst = st[NSV_ST_AUDIO]->priv_data;
|
||||
pkt = &nsv->ahead[NSV_ST_AUDIO];
|
||||
/* read raw audio specific header on the first audio chunk... */
|
||||
|
@@ -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