Compare commits
61 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
62133b38ed | ||
![]() |
6b14563c0e | ||
![]() |
3074e8f78c | ||
![]() |
e37599001c | ||
![]() |
32ac7c0cf6 | ||
![]() |
9291fc8813 | ||
![]() |
62cbdd71eb | ||
![]() |
42bdeaecd4 | ||
![]() |
438cfa9090 | ||
![]() |
64eb6892ec | ||
![]() |
888cee659e | ||
![]() |
598eb973a7 | ||
![]() |
4451f9ae16 | ||
![]() |
83fa442b71 | ||
![]() |
679de9b5aa | ||
![]() |
e17b1536a1 | ||
![]() |
97ed486fff | ||
![]() |
77630b68e5 | ||
![]() |
732dbc0f03 | ||
![]() |
68d2c6e872 | ||
![]() |
4bccd5a36b | ||
![]() |
07bff95176 | ||
![]() |
cfad9930ff | ||
![]() |
46d9022859 | ||
![]() |
58b3f439cc | ||
![]() |
8f924ee66f | ||
![]() |
40cb7b3b49 | ||
![]() |
15c819e23f | ||
![]() |
7a5fbe4034 | ||
![]() |
32b73701c7 | ||
![]() |
212217504a | ||
![]() |
e02249b130 | ||
![]() |
bf0ec375ef | ||
![]() |
e9c9707316 | ||
![]() |
5933af562e | ||
![]() |
1156f07c6a | ||
![]() |
6ca010f209 | ||
![]() |
224025d852 | ||
![]() |
a8f4db0acd | ||
![]() |
b46141b0d1 | ||
![]() |
38421f27b3 | ||
![]() |
3253dd2b42 | ||
![]() |
87007519c8 | ||
![]() |
1edf848a81 | ||
![]() |
b56606e6bc | ||
![]() |
113ca1b8db | ||
![]() |
f70c720d42 | ||
![]() |
1014e20492 | ||
![]() |
431cf16963 | ||
![]() |
e85296beae | ||
![]() |
62c4739348 | ||
![]() |
7efa13b4b4 | ||
![]() |
a5e0afe3c9 | ||
![]() |
42f0a66968 | ||
![]() |
f1c9dbe40b | ||
![]() |
b945f558c7 | ||
![]() |
90a4a46747 | ||
![]() |
6d6254ba9f | ||
![]() |
ae24b5ce3a | ||
![]() |
c9c7db0af2 | ||
![]() |
e1a2bcbec8 |
45
Changelog
45
Changelog
@@ -1,6 +1,51 @@
|
||||
Entries are sorted chronologically from oldest to youngest within each release,
|
||||
releases are sorted from youngest to oldest.
|
||||
|
||||
version 0.6.6:
|
||||
- id3v2: fix skipping extended header in id3v2.4
|
||||
- nsvdec: Fix use of uninitialized streams
|
||||
- nsvdec: Be more careful with av_malloc()
|
||||
- nsvdec: Propagate errors
|
||||
- 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
|
||||
- mjpegbdec: Fix overflow in SOS
|
||||
- kgv1dec: Increase offsets array size so it is large enough
|
||||
- motionpixels: decode only the 111 complete frames for fate
|
||||
- motionpixels: Clip YUV values after applying a gradient
|
||||
- celp filters: Do not read earlier than the start of the 'out' vector
|
||||
- vqavideo: return error if image size is not a multiple of block size (CVE-2012-0947)
|
||||
- dpcm: ignore extra unpaired bytes in stereo streams (CVE-2011-3951)
|
||||
- aacsbr: prevent out of bounds memcpy() (CVE-2012-0850)
|
||||
- h264: Add check for invalid chroma_format_idc (CVE-2012-0851)
|
||||
- adpcm: ADPCM Electronic Arts has always two channels (CVE-2012-0852)
|
||||
- shorten: remove VLA and check for buffer overflow
|
||||
- shorten: Prevent block size from increasing
|
||||
- shorten: Fix out of bound writes in fix_bitshift()
|
||||
- shorten: check for realloc failure (CVE-2012-0858)
|
||||
- shorten: Use separate pointers for the allocated memory for decoded samples (CVE-2012-0858)
|
||||
- kmvc: Check palsize (CVE-2011-3952)
|
||||
- qdm2: clip array indices returned by qdm2_get_vlc()
|
||||
- configure: properly check for mingw-w64 through installed headers
|
||||
- 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
|
||||
- dxva2: define required feature selection macros
|
||||
- png: check bit depth for PAL8/Y400A pixel formats
|
||||
- ea: check chunk_size for validity
|
||||
- tqi: Pass errors from the MB decoder
|
||||
|
||||
|
||||
version 0.6.5:
|
||||
- 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.6.4:
|
||||
- 4xm: Add a check in decode_i_frame to prevent buffer overreads
|
||||
- wma: initialize prev_block_len_bits, next_block_len_bits, and block_len_bits.
|
||||
|
34
RELEASE
34
RELEASE
@@ -176,3 +176,37 @@ Sierra VMD decoder CVE-2011-4364, and a safety fix in the svq1 decoder
|
||||
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.6.5
|
||||
|
||||
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.6.6
|
||||
|
||||
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 fixes, this release features includes
|
||||
security updates for the, DV decoder (CVE-2011-3929 and CVE-2011-3936),
|
||||
VQA Video Decoder (CVE-2012-0947), DPCM codecs (CVE-2011-3951), AAC SBR
|
||||
(CVE-2012-0850), H.264 (CVE-2012-0851), ADPCM (CVE-2012-0852), Shorten
|
||||
(CVE-2012-0858), 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.
|
||||
|
13
configure
vendored
13
configure
vendored
@@ -1412,7 +1412,7 @@ oss_indev_deps_any="soundcard_h sys_soundcard_h"
|
||||
oss_outdev_deps_any="soundcard_h sys_soundcard_h"
|
||||
v4l_indev_deps="linux_videodev_h"
|
||||
v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h"
|
||||
vfwcap_indev_deps="capCreateCaptureWindow"
|
||||
vfwcap_indev_deps="capCreateCaptureWindow vfwcap_defines"
|
||||
vfwcap_indev_extralibs="-lavicap32"
|
||||
x11_grab_device_indev_deps="x11grab XShmCreateImage"
|
||||
x11_grab_device_indev_extralibs="-lX11 -lXext -lXfixes"
|
||||
@@ -2230,13 +2230,9 @@ case $target_os in
|
||||
dlltool="${cross_prefix}dlltool"
|
||||
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_indev &&
|
||||
{ check_cpp_condition w32api.h "(__W32API_MAJOR_VERSION > 3) || (__W32API_MAJOR_VERSION == 3 && __W32API_MINOR_VERSION >= 13)" ||
|
||||
die "ERROR: avisynth and vfwcap_indev require w32api version 3.13 or later."; }
|
||||
fi
|
||||
;;
|
||||
cygwin*)
|
||||
target_os=cygwin
|
||||
@@ -2689,6 +2685,9 @@ check_header linux/videodev2.h
|
||||
check_header sys/videoio.h
|
||||
|
||||
check_func_headers "windows.h vfw.h" capCreateCaptureWindow "$vfwcap_indev_extralibs"
|
||||
# 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 &&
|
||||
|
@@ -1182,14 +1182,15 @@ static void sbr_qmf_synthesis(DSPContext *dsp, FFTContext *mdct,
|
||||
int i, n;
|
||||
const float *sbr_qmf_window = div ? sbr_qmf_window_ds : sbr_qmf_window_us;
|
||||
int scale_and_bias = scale != 1.0f || bias != 0.0f;
|
||||
const int step = 128 >> div;
|
||||
float *v;
|
||||
for (i = 0; i < 32; i++) {
|
||||
if (*v_off == 0) {
|
||||
if (*v_off < step) {
|
||||
int saved_samples = (1280 - 128) >> div;
|
||||
memcpy(&v0[SBR_SYNTHESIS_BUF_SIZE - saved_samples], v0, saved_samples * sizeof(float));
|
||||
*v_off = SBR_SYNTHESIS_BUF_SIZE - saved_samples - (128 >> div);
|
||||
*v_off = SBR_SYNTHESIS_BUF_SIZE - saved_samples - step;
|
||||
} else {
|
||||
*v_off -= 128 >> div;
|
||||
*v_off -= step;
|
||||
}
|
||||
v = v0 + *v_off;
|
||||
if (div) {
|
||||
|
@@ -678,17 +678,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) {
|
||||
|
@@ -393,6 +393,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;
|
||||
|
@@ -280,6 +280,10 @@ static int cdg_decode_frame(AVCodecContext *avctx,
|
||||
av_log(avctx, AV_LOG_ERROR, "buffer too small for decoder\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
if (buf_size > CDG_HEADER_SIZE + CDG_DATA_SIZE) {
|
||||
av_log(avctx, AV_LOG_ERROR, "buffer too big for decoder\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
ret = avctx->reget_buffer(avctx, &cc->frame);
|
||||
if (ret) {
|
||||
|
@@ -133,9 +133,8 @@ void ff_celp_lp_synthesis_filterf(float *out, const float *filter_coeffs,
|
||||
out2 -= val * old_out2;
|
||||
out3 -= val * old_out3;
|
||||
|
||||
old_out3 = out[-5];
|
||||
|
||||
for (i = 5; i <= filter_length; i += 2) {
|
||||
old_out3 = out[-i];
|
||||
val = filter_coeffs[i-1];
|
||||
|
||||
out0 -= val * old_out3;
|
||||
@@ -154,7 +153,6 @@ void ff_celp_lp_synthesis_filterf(float *out, const float *filter_coeffs,
|
||||
|
||||
FFSWAP(float, old_out0, old_out2);
|
||||
old_out1 = old_out3;
|
||||
old_out3 = out[-i-2];
|
||||
}
|
||||
|
||||
tmp0 = out0;
|
||||
|
@@ -169,6 +169,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;
|
||||
@@ -177,6 +178,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;
|
||||
@@ -295,7 +299,7 @@ static int dpcm_decode_frame(AVCodecContext *avctx,
|
||||
}
|
||||
|
||||
*data_size = out * sizeof(short);
|
||||
return buf_size;
|
||||
return avpkt->size;
|
||||
}
|
||||
|
||||
#define DPCM_DECODER(id, name, long_name_) \
|
||||
|
@@ -23,6 +23,8 @@
|
||||
#ifndef AVCODEC_DXVA_INTERNAL_H
|
||||
#define AVCODEC_DXVA_INTERNAL_H
|
||||
|
||||
#define _WIN32_WINNT 0x0600
|
||||
#define COBJMACROS
|
||||
#include "dxva2.h"
|
||||
#include "avcodec.h"
|
||||
#include "mpegvideo.h"
|
||||
|
@@ -59,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])
|
||||
@@ -136,7 +139,8 @@ 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, t->block);
|
||||
if (tqi_decode_mb(s, t->block) < 0)
|
||||
break;
|
||||
tqi_idct_put(t, t->block);
|
||||
}
|
||||
|
||||
|
@@ -1048,7 +1048,7 @@ static void fill_decode_caches(H264Context *h, int mb_type){
|
||||
AV_ZERO32(h->mv_cache [list][scan8[0] + 4 - 1*8]);
|
||||
h->ref_cache[list][scan8[0] + 4 - 1*8]= topright_type ? LIST_NOT_USED : PART_NOT_AVAILABLE;
|
||||
}
|
||||
if(h->ref_cache[list][scan8[0] + 4 - 1*8] < 0){
|
||||
if(h->ref_cache[list][scan8[0] + 2 - 1*8] < 0 || h->ref_cache[list][scan8[0] + 4 - 1*8] < 0){
|
||||
if(USES_LIST(topleft_type, list)){
|
||||
const int b_xy = h->mb2b_xy [topleft_xy] + 3 + h->b_stride + (h->topleft_partition & 2*h->b_stride);
|
||||
const int b8_xy= 4*topleft_xy + 1 + (h->topleft_partition & 2);
|
||||
|
@@ -297,8 +297,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 > 3U) {
|
||||
av_log(h->s.avctx, AV_LOG_ERROR, "chroma_format_idc %d is illegal\n", sps->chroma_format_idc);
|
||||
goto fail;
|
||||
} 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);
|
||||
|
@@ -72,7 +72,7 @@ int ff_intel_h263_decode_picture_header(MpegEncContext *s)
|
||||
}
|
||||
if(get_bits(&s->gb, 2))
|
||||
av_log(s->avctx, AV_LOG_ERROR, "Bad value for reserved field\n");
|
||||
s->loop_filter = get_bits1(&s->gb);
|
||||
s->loop_filter = get_bits1(&s->gb) * !s->avctx->lowres;
|
||||
if(get_bits1(&s->gb))
|
||||
av_log(s->avctx, AV_LOG_ERROR, "Bad value for reserved field\n");
|
||||
if(get_bits1(&s->gb))
|
||||
|
@@ -961,6 +961,8 @@ int h263_decode_picture_header(MpegEncContext *s)
|
||||
s->h263_aic = get_bits1(&s->gb); /* Advanced Intra Coding (AIC) */
|
||||
s->loop_filter= get_bits1(&s->gb);
|
||||
s->unrestricted_mv = s->umvplus || s->obmc || s->loop_filter;
|
||||
if(s->avctx->lowres)
|
||||
s->loop_filter = 0;
|
||||
|
||||
s->h263_slice_structured= get_bits1(&s->gb);
|
||||
if (get_bits1(&s->gb) != 0) {
|
||||
|
@@ -38,7 +38,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
|
||||
const uint8_t *buf = avpkt->data;
|
||||
const uint8_t *buf_end = buf + avpkt->size;
|
||||
KgvContext * const c = avctx->priv_data;
|
||||
int offsets[7];
|
||||
int offsets[8];
|
||||
uint16_t *out, *prev;
|
||||
int outcnt = 0, maxcnt;
|
||||
int w, h, i;
|
||||
@@ -68,7 +68,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
|
||||
return -1;
|
||||
c->prev = prev;
|
||||
|
||||
for (i = 0; i < 7; i++)
|
||||
for (i = 0; i < 8; i++)
|
||||
offsets[i] = -1;
|
||||
|
||||
while (outcnt < maxcnt && buf_end - 2 > buf) {
|
||||
|
@@ -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;
|
||||
@@ -365,6 +366,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
|
||||
|
@@ -59,6 +59,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 */
|
||||
@@ -109,8 +112,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);
|
||||
|
@@ -53,6 +53,11 @@ static av_cold int mp_decode_init(AVCodecContext *avctx)
|
||||
{
|
||||
MotionPixelsContext *mp = avctx->priv_data;
|
||||
|
||||
if(avctx->extradata_size < 2){
|
||||
av_log(avctx, AV_LOG_ERROR, "extradata too small\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
motionpixels_tableinit();
|
||||
mp->avctx = avctx;
|
||||
dsputil_init(&mp->dsp, avctx);
|
||||
@@ -188,10 +193,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;
|
||||
@@ -215,9 +223,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);
|
||||
|
@@ -487,9 +487,11 @@ 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 if (s->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
|
||||
} else if (s->bit_depth == 8 &&
|
||||
s->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
|
||||
avctx->pix_fmt = PIX_FMT_Y400A;
|
||||
} else {
|
||||
goto fail;
|
||||
|
@@ -883,9 +883,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;
|
||||
@@ -899,8 +903,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);
|
||||
|
@@ -82,7 +82,9 @@ typedef struct ShortenContext {
|
||||
int channels;
|
||||
|
||||
int32_t *decoded[MAX_CHANNELS];
|
||||
int32_t *decoded_base[MAX_CHANNELS];
|
||||
int32_t *offset[MAX_CHANNELS];
|
||||
int *coeffs;
|
||||
uint8_t *bitstream;
|
||||
int bitstream_size;
|
||||
int bitstream_index;
|
||||
@@ -112,6 +114,9 @@ static av_cold int shorten_decode_init(AVCodecContext * avctx)
|
||||
static int allocate_buffers(ShortenContext *s)
|
||||
{
|
||||
int i, chan;
|
||||
int *coeffs;
|
||||
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,13 +127,26 @@ 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;
|
||||
}
|
||||
|
||||
coeffs = av_realloc(s->coeffs, s->nwrap * sizeof(*s->coeffs));
|
||||
if (!coeffs)
|
||||
return AVERROR(ENOMEM);
|
||||
s->coeffs = coeffs;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -147,7 +165,7 @@ static void fix_bitshift(ShortenContext *s, int32_t *buffer)
|
||||
|
||||
if (s->bitshift != 0)
|
||||
for (i = 0; i < s->blocksize; i++)
|
||||
buffer[s->nwrap + i] <<= s->bitshift;
|
||||
buffer[i] <<= s->bitshift;
|
||||
}
|
||||
|
||||
|
||||
@@ -253,7 +271,7 @@ static int16_t * interleave_buffer(int16_t *samples, int nchan, int blocksize, i
|
||||
static void decode_subframe_lpc(ShortenContext *s, int channel, int residual_size, int pred_order)
|
||||
{
|
||||
int sum, i, j;
|
||||
int coeffs[pred_order];
|
||||
int *coeffs = s->coeffs;
|
||||
|
||||
for (i=0; i<pred_order; i++)
|
||||
coeffs[i] = get_sr_golomb_shorten(&s->gb, LPCQUANT);
|
||||
@@ -277,8 +295,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
|
||||
@@ -427,6 +452,12 @@ static int shorten_decode_frame(AVCodecContext *avctx,
|
||||
case FN_QLPC:
|
||||
{
|
||||
int pred_order = get_ur_golomb_shorten(&s->gb, LPCQSIZE);
|
||||
if (pred_order > s->nwrap) {
|
||||
av_log(avctx, AV_LOG_ERROR,
|
||||
"invalid pred_order %d\n",
|
||||
pred_order);
|
||||
return -1;
|
||||
}
|
||||
for (i=0; i<pred_order; i++)
|
||||
s->decoded[channel][i - pred_order] -= coffset;
|
||||
decode_subframe_lpc(s, channel, residual_size, pred_order);
|
||||
@@ -471,9 +502,15 @@ static int shorten_decode_frame(AVCodecContext *avctx,
|
||||
case FN_BITSHIFT:
|
||||
s->bitshift = get_ur_golomb_shorten(&s->gb, BITSHIFTSIZE);
|
||||
break;
|
||||
case FN_BLOCKSIZE:
|
||||
s->blocksize = get_uint(s, av_log2(s->blocksize));
|
||||
case FN_BLOCKSIZE: {
|
||||
int blocksize = get_uint(s, av_log2(s->blocksize));
|
||||
if (blocksize > s->blocksize) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Increasing block size is not supported\n");
|
||||
return AVERROR_PATCHWELCOME;
|
||||
}
|
||||
s->blocksize = blocksize;
|
||||
break;
|
||||
}
|
||||
case FN_QUIT:
|
||||
*data_size = 0;
|
||||
return buf_size;
|
||||
@@ -510,11 +547,12 @@ 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);
|
||||
av_freep(&s->coeffs);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -518,6 +518,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) { \
|
||||
@@ -535,6 +539,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) { \
|
||||
@@ -553,6 +561,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) { \
|
||||
@@ -570,6 +582,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) { \
|
||||
|
@@ -156,7 +156,7 @@ void ff_vorbis_ready_floor1_list(vorbis_floor1_entry * list, int values)
|
||||
}
|
||||
}
|
||||
|
||||
static inline void render_line_unrolled(intptr_t x, intptr_t y, int x1,
|
||||
static inline void render_line_unrolled(intptr_t x, uint8_t y, int x1,
|
||||
intptr_t sy, int ady, int adx,
|
||||
float *buf)
|
||||
{
|
||||
@@ -179,7 +179,7 @@ static inline void render_line_unrolled(intptr_t x, intptr_t y, int x1,
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -189,10 +189,10 @@ static void render_line(int x0, int y0, int x1, int y1, float *buf)
|
||||
if (ady*2 <= adx) { // optimized common case
|
||||
render_line_unrolled(x0, y0, x1, sy, ady, adx, buf);
|
||||
} else {
|
||||
int base = dy / adx;
|
||||
int x = x0;
|
||||
int y = y0;
|
||||
int err = -adx;
|
||||
int base = dy / adx;
|
||||
int x = x0;
|
||||
uint8_t y = y0;
|
||||
int err = -adx;
|
||||
ady -= FFABS(base) * adx;
|
||||
while (++x < x1) {
|
||||
y += base;
|
||||
@@ -210,7 +210,8 @@ 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++) {
|
||||
|
@@ -656,7 +656,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: %"PRIdFAST16", %"PRIdFAST32", %"PRIdFAST32", %"PRIdFAST32", %"PRIdFAST32"\n", res_setup->type, res_setup->begin, res_setup->end, res_setup->partition_size, vc->blocksize[1] / 2);
|
||||
return -1;
|
||||
@@ -1262,6 +1262,7 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc,
|
||||
uint_fast8_t *do_not_decode,
|
||||
float *vec,
|
||||
uint_fast16_t vlen,
|
||||
unsigned ch_left,
|
||||
int vr_type)
|
||||
{
|
||||
GetBitContext *gb = &vc->gb;
|
||||
@@ -1273,6 +1274,7 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc,
|
||||
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)
|
||||
@@ -1280,8 +1282,15 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc,
|
||||
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);
|
||||
@@ -1403,14 +1412,16 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc,
|
||||
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)
|
||||
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);
|
||||
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, 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, 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;
|
||||
@@ -1473,6 +1484,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");
|
||||
@@ -1491,11 +1504,12 @@ 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
|
||||
|
||||
@@ -1515,7 +1529,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
|
||||
@@ -1532,6 +1546,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])) {
|
||||
@@ -1546,9 +1561,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
|
||||
|
@@ -884,7 +884,7 @@ static int unpack_vlcs(Vp3DecodeContext *s, GetBitContext *gb,
|
||||
/* decode a VLC into a token */
|
||||
token = get_vlc2(gb, vlc_table, 11, 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]);
|
||||
@@ -902,7 +902,7 @@ static int unpack_vlcs(Vp3DecodeContext *s, GetBitContext *gb,
|
||||
coeff_i += eob_run;
|
||||
eob_run = 0;
|
||||
}
|
||||
} else {
|
||||
} else if (token >= 0) {
|
||||
bits_to_get = coeff_get_bits[token];
|
||||
if (bits_to_get)
|
||||
bits_to_get = get_bits(gb, bits_to_get);
|
||||
@@ -936,6 +936,10 @@ static int unpack_vlcs(Vp3DecodeContext *s, GetBitContext *gb,
|
||||
for (i = coeff_index+1; i <= coeff_index+zero_run; i++)
|
||||
s->num_coded_frags[plane][i]--;
|
||||
coeff_i++;
|
||||
} else {
|
||||
av_log(s->avctx, AV_LOG_ERROR,
|
||||
"Invalid token %d\n", token);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -985,6 +989,8 @@ static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBitContext *gb)
|
||||
/* unpack the Y plane DC coefficients */
|
||||
residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_y_table], 0,
|
||||
0, residual_eob_run);
|
||||
if (residual_eob_run < 0)
|
||||
return residual_eob_run;
|
||||
|
||||
/* reverse prediction of the Y-plane DC coefficients */
|
||||
reverse_dc_prediction(s, 0, s->fragment_width[0], s->fragment_height[0]);
|
||||
@@ -992,8 +998,12 @@ 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,
|
||||
1, residual_eob_run);
|
||||
if (residual_eob_run < 0)
|
||||
return residual_eob_run;
|
||||
residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_c_table], 0,
|
||||
2, residual_eob_run);
|
||||
if (residual_eob_run < 0)
|
||||
return residual_eob_run;
|
||||
|
||||
/* reverse prediction of the C-plane DC coefficients */
|
||||
if (!(s->avctx->flags & CODEC_FLAG_GRAY))
|
||||
@@ -1030,11 +1040,17 @@ static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBitContext *gb)
|
||||
for (i = 1; i <= 63; i++) {
|
||||
residual_eob_run = unpack_vlcs(s, gb, y_tables[i], i,
|
||||
0, residual_eob_run);
|
||||
if (residual_eob_run < 0)
|
||||
return residual_eob_run;
|
||||
|
||||
residual_eob_run = unpack_vlcs(s, gb, c_tables[i], i,
|
||||
1, residual_eob_run);
|
||||
if (residual_eob_run < 0)
|
||||
return residual_eob_run;
|
||||
residual_eob_run = unpack_vlcs(s, gb, c_tables[i], i,
|
||||
2, residual_eob_run);
|
||||
if (residual_eob_run < 0)
|
||||
return residual_eob_run;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -1300,6 +1316,8 @@ static inline int vp3_dequant(Vp3DecodeContext *s, Vp3Fragment *frag,
|
||||
return i;
|
||||
}
|
||||
} while (i < 64);
|
||||
// return value is expected to be a valid level
|
||||
i--;
|
||||
end:
|
||||
// the actual DC+prediction is in the fragment structure
|
||||
block[0] = frag->dc * s->qmat[0][inter][plane][0];
|
||||
@@ -1462,10 +1480,7 @@ static void render_slice(Vp3DecodeContext *s, int slice)
|
||||
/* invert DCT and place (or add) in final output */
|
||||
|
||||
if (s->all_fragments[i].coding_method == MODE_INTRA) {
|
||||
int index;
|
||||
index = vp3_dequant(s, s->all_fragments + i, plane, 0, block);
|
||||
if (index > 63)
|
||||
continue;
|
||||
vp3_dequant(s, s->all_fragments + i, plane, 0, block);
|
||||
if(s->avctx->idct_algo!=FF_IDCT_VP3)
|
||||
block[0] += 128<<3;
|
||||
s->dsp.idct_put(
|
||||
@@ -1473,10 +1488,7 @@ static void render_slice(Vp3DecodeContext *s, int slice)
|
||||
stride,
|
||||
block);
|
||||
} else {
|
||||
int index = vp3_dequant(s, s->all_fragments + i, plane, 1, block);
|
||||
if (index > 63)
|
||||
continue;
|
||||
if (index > 0) {
|
||||
if (vp3_dequant(s, s->all_fragments + i, plane, 1, block)) {
|
||||
s->dsp.idct_add(
|
||||
output_plane + first_pixel,
|
||||
stride,
|
||||
|
@@ -162,6 +162,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);
|
||||
|
@@ -70,6 +70,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");
|
||||
|
@@ -417,7 +417,7 @@ cglobal scalarproduct_float_sse, 3,3,2, v1, v2, offset
|
||||
shufps xmm0, xmm0, 1
|
||||
addss xmm0, xmm1
|
||||
%ifndef ARCH_X86_64
|
||||
movd r0m, xmm0
|
||||
movss r0m, xmm0
|
||||
fld dword r0m
|
||||
%endif
|
||||
RET
|
||||
|
@@ -89,6 +89,11 @@ static av_cold int yop_decode_init(AVCodecContext *avctx)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!avctx->extradata) {
|
||||
av_log(avctx, AV_LOG_ERROR, "extradata missing\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
avctx->pix_fmt = PIX_FMT_PAL8;
|
||||
|
||||
s->num_pal_colors = avctx->extradata[0];
|
||||
@@ -198,6 +203,11 @@ static int yop_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
|
||||
if (s->frame.data[0])
|
||||
avctx->release_buffer(avctx, &s->frame);
|
||||
|
||||
if (avpkt->size < 4 + 3*s->num_pal_colors) {
|
||||
av_log(avctx, AV_LOG_ERROR, "packet of size %d too small\n", avpkt->size);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
ret = avctx->get_buffer(avctx, &s->frame);
|
||||
if (ret < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
@@ -213,6 +223,10 @@ static int yop_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
|
||||
s->low_nibble = NULL;
|
||||
|
||||
is_odd_frame = avpkt->data[0];
|
||||
if(is_odd_frame>1){
|
||||
av_log(avctx, AV_LOG_ERROR, "frame is too odd %d\n", is_odd_frame);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
firstcolor = s->first_color[is_odd_frame];
|
||||
palette = (uint32_t *)s->frame.data[1];
|
||||
|
||||
|
@@ -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);
|
||||
|
||||
/* We work with 720p frames split in half, thus even frames have
|
||||
* channels 0,1 and odd 2,3. */
|
||||
|
@@ -457,12 +457,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:
|
||||
|
@@ -187,8 +187,17 @@ void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t flags)
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (isv34 && flags & 0x40) /* Extended header present, just skip over it */
|
||||
url_fskip(s->pb, get_size(s->pb, 4));
|
||||
if (isv34 && flags & 0x40) { /* Extended header present, just skip over it */
|
||||
int extlen = 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) {
|
||||
|
@@ -1074,13 +1074,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
|
||||
|
@@ -319,7 +319,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) {
|
||||
@@ -354,6 +356,8 @@ static int nsv_parse_NSVf_header(AVFormatContext *s, AVFormatParameters *ap)
|
||||
if((unsigned)table_entries_used >= UINT_MAX / sizeof(uint32_t))
|
||||
return -1;
|
||||
nsv->nsvs_file_offset = av_malloc((unsigned)table_entries_used * sizeof(uint32_t));
|
||||
if (!nsv->nsvs_file_offset)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
for(i=0;i<table_entries_used;i++)
|
||||
nsv->nsvs_file_offset[i] = get_le32(pb) + size;
|
||||
@@ -361,6 +365,8 @@ static int nsv_parse_NSVf_header(AVFormatContext *s, AVFormatParameters *ap)
|
||||
if(table_entries > table_entries_used &&
|
||||
get_le32(pb) == MKTAG('T','O','C','2')) {
|
||||
nsv->nsvs_timestamps = av_malloc((unsigned)table_entries_used*sizeof(uint32_t));
|
||||
if (!nsv->nsvs_timestamps)
|
||||
return AVERROR(ENOMEM);
|
||||
for(i=0;i<table_entries_used;i++) {
|
||||
nsv->nsvs_timestamps[i] = get_le32(pb);
|
||||
}
|
||||
@@ -530,11 +536,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 */
|
||||
}
|
||||
}
|
||||
@@ -609,12 +620,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);
|
||||
@@ -629,7 +640,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... */
|
||||
|
@@ -503,7 +503,7 @@ fate-maxis-xa: CMD = $$BUILD_PATH/ffmpeg -i $$SAMPLES_PATH/maxis-xa/SC2KBUG.XA
|
||||
FATE_TESTS += fate-mimic
|
||||
fate-mimic: CMD = $$BUILD_PATH/ffmpeg -idct simple -i $$SAMPLES_PATH/mimic/mimic2-womanloveffmpeg.cam -vsync 0 -f framecrc -
|
||||
FATE_TESTS += fate-motionpixels
|
||||
fate-motionpixels: CMD = $$BUILD_PATH/ffmpeg -i $$SAMPLES_PATH/motion-pixels/INTRO-partial.MVI -an -pix_fmt rgb24 -f framecrc -
|
||||
fate-motionpixels: CMD = $$BUILD_PATH/ffmpeg -i $$SAMPLES_PATH/motion-pixels/INTRO-partial.MVI -an -pix_fmt rgb24 -vframes 111 -f framecrc -
|
||||
FATE_TESTS += fate-mpc7-demux
|
||||
fate-mpc7-demux: CMD = $$BUILD_PATH/ffmpeg -i $$SAMPLES_PATH/musepack/inside-mp7.mpc -acodec copy -f crc -
|
||||
FATE_TESTS += fate-mpc8-demux
|
||||
|
@@ -109,4 +109,3 @@
|
||||
0, 648003, 230400, 0xb343f372
|
||||
0, 654003, 230400, 0xf7f1e588
|
||||
0, 660003, 230400, 0x9682bdb2
|
||||
0, 666003, 230400, 0x538a3db8
|
||||
|
Reference in New Issue
Block a user