summaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-03-29 01:41:04 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-03-29 04:11:10 +0200
commitd40ff29cacf9b8ffa1061392a0e9b3056c4882ea (patch)
tree3b59f4b9a74e209220f0b0dcb90c466e3e4a9b3d /libavcodec
parent99bb88c588ea9a46a06b966b9014394385ebe1c3 (diff)
parent44257ef4267f01dd698c8ab8abf50fd77136a8ce (diff)
downloadffmpeg-streaming-d40ff29cacf9b8ffa1061392a0e9b3056c4882ea.zip
ffmpeg-streaming-d40ff29cacf9b8ffa1061392a0e9b3056c4882ea.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: asf: only set index_read if the index contained entries. cabac: add overread protection to BRANCHLESS_GET_CABAC(). cabac: increment jump locations by one in callers of BRANCHLESS_GET_CABAC(). cabac: remove unused argument from BRANCHLESS_GET_CABAC_UPDATE(). cabac: use struct+offset instead of memory operand in BRANCHLESS_GET_CABAC(). h264: add overread protection to get_cabac_bypass_sign_x86(). h264: reindent get_cabac_bypass_sign_x86(). h264: use struct offsets in get_cabac_bypass_sign_x86(). h264: fix overreads in cabac reader. wmall: fix seeking. lagarith: fix buffer overreads. dvdec: drop unnecessary dv_tablegen.h #include build: fix doc generation errors in parallel builds Replace memset(0) by zero initializations. faandct: Remove FAAN_POSTSCALE define and related code. dvenc: print allowed profiles if the video doesn't conform to any of them. avcodec_encode_{audio,video}: only reallocate output packet when it has non-zero size. FATE: add a test for vp8 with changing frame size. fate: add kgv1 fate test. oggdec: calculate correct timestamps in Ogg/FLAC Conflicts: libavcodec/4xm.c libavcodec/cook.c libavcodec/dvdata.c libavcodec/dvdsubdec.c libavcodec/lagarith.c libavcodec/lagarithrac.c libavcodec/utils.c tests/fate/video.mak Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/4xm.c6
-rw-r--r--libavcodec/aaccoder.c3
-rw-r--r--libavcodec/aacpsy.c6
-rw-r--r--libavcodec/ac3dec.c4
-rw-r--r--libavcodec/alsdec.c11
-rw-r--r--libavcodec/bink.c3
-rw-r--r--libavcodec/cabac_functions.h4
-rw-r--r--libavcodec/cook.c20
-rw-r--r--libavcodec/dct-test.c8
-rw-r--r--libavcodec/dv.c6
-rw-r--r--libavcodec/dvdata.c12
-rw-r--r--libavcodec/dvdata.h5
-rw-r--r--libavcodec/dvdec.c1
-rw-r--r--libavcodec/dvdsubdec.c6
-rw-r--r--libavcodec/dxva2.c3
-rw-r--r--libavcodec/faandct.c37
-rw-r--r--libavcodec/faandct.h2
-rw-r--r--libavcodec/flac_parser.c3
-rw-r--r--libavcodec/intrax8dsp.c6
-rw-r--r--libavcodec/jpeglsenc.c3
-rw-r--r--libavcodec/lagarith.c71
-rw-r--r--libavcodec/lagarithrac.c6
-rw-r--r--libavcodec/libxvid_rc.c9
-rw-r--r--libavcodec/libxvidff.c21
-rw-r--r--libavcodec/mjpegdec.c3
-rw-r--r--libavcodec/motion_est.c3
-rw-r--r--libavcodec/mpegaudiodec.c7
-rw-r--r--libavcodec/mpegvideo_enc.c25
-rw-r--r--libavcodec/ra144enc.c3
-rw-r--r--libavcodec/rangecoder.c2
-rw-r--r--libavcodec/rv34.c5
-rw-r--r--libavcodec/smacker.c11
-rw-r--r--libavcodec/tiff.c3
-rw-r--r--libavcodec/truemotion1.c3
-rw-r--r--libavcodec/wmalosslessdec.c13
-rw-r--r--libavcodec/wmaprodec.c4
-rw-r--r--libavcodec/wmavoice.c3
-rw-r--r--libavcodec/x86/cabac.h78
-rw-r--r--libavcodec/x86/h264_i386.h62
39 files changed, 230 insertions, 251 deletions
diff --git a/libavcodec/4xm.c b/libavcodec/4xm.c
index 53ee855..600cf81 100644
--- a/libavcodec/4xm.c
+++ b/libavcodec/4xm.c
@@ -578,7 +578,7 @@ static int decode_i_mb(FourXContext *f)
static const uint8_t *read_huffman_tables(FourXContext *f,
const uint8_t * const buf, int buf_size)
{
- int frequency[512];
+ int frequency[512] = { 0 };
uint8_t flag[512];
int up[512];
uint8_t len_tab[257];
@@ -588,7 +588,6 @@ static const uint8_t *read_huffman_tables(FourXContext *f,
const uint8_t *ptr_end = buf + buf_size;
int j;
- memset(frequency, 0, sizeof(frequency));
memset(up, -1, sizeof(up));
start = *ptr++;
@@ -691,10 +690,9 @@ static int decode_i2_frame(FourXContext *f, const uint8_t *buf, int length)
for (y = 0; y < height; y += 16) {
for (x = 0; x < width; x += 16) {
- unsigned int color[4], bits;
+ unsigned int color[4] = { 0 }, bits;
if (buf_end - buf < 8)
return -1;
- memset(color, 0, sizeof(color));
// warning following is purely guessed ...
color[0] = bytestream2_get_le16u(&g3);
color[1] = bytestream2_get_le16u(&g3);
diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c
index 8738460..25187b7 100644
--- a/libavcodec/aaccoder.c
+++ b/libavcodec/aaccoder.c
@@ -714,7 +714,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx,
{
int start = 0, i, w, w2, g;
int destbits = avctx->bit_rate * 1024.0 / avctx->sample_rate / avctx->channels;
- float dists[128], uplims[128];
+ float dists[128] = { 0 }, uplims[128];
float maxvals[128];
int fflag, minscaler;
int its = 0;
@@ -722,7 +722,6 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx,
float minthr = INFINITY;
//XXX: some heuristic to determine initial quantizers will reduce search time
- memset(dists, 0, sizeof(dists));
//determine zero bands and upper limits
for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
for (g = 0; g < sce->ics.num_swb; g++) {
diff --git a/libavcodec/aacpsy.c b/libavcodec/aacpsy.c
index 396a2d2..77dfec6 100644
--- a/libavcodec/aacpsy.c
+++ b/libavcodec/aacpsy.c
@@ -389,9 +389,8 @@ static av_unused FFPsyWindowInfo psy_3gpp_window(FFPsyContext *ctx,
AacPsyChannel *pch = &pctx->ch[channel];
uint8_t grouping = 0;
int next_type = pch->next_window_seq;
- FFPsyWindowInfo wi;
+ FFPsyWindowInfo wi = { { 0 } };
- memset(&wi, 0, sizeof(wi));
if (la) {
float s[8], v;
int switch_to_eight = 0;
@@ -785,9 +784,8 @@ static FFPsyWindowInfo psy_lame_window(FFPsyContext *ctx, const float *audio,
int uselongblock = 1;
int attacks[AAC_NUM_BLOCKS_SHORT + 1] = { 0 };
int i;
- FFPsyWindowInfo wi;
+ FFPsyWindowInfo wi = { { 0 } };
- memset(&wi, 0, sizeof(wi));
if (la) {
float hpfsmpl[AAC_BLOCK_SIZE_LONG];
float const *pf = hpfsmpl;
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index 31891b5..6c1fdbe 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -753,9 +753,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
int downmix_output;
int cpl_in_use;
GetBitContext *gbc = &s->gbc;
- uint8_t bit_alloc_stages[AC3_MAX_CHANNELS];
-
- memset(bit_alloc_stages, 0, AC3_MAX_CHANNELS);
+ uint8_t bit_alloc_stages[AC3_MAX_CHANNELS] = { 0 };
/* block switch flags */
different_transforms = 0;
diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c
index e61c29e..b98473e 100644
--- a/libavcodec/alsdec.c
+++ b/libavcodec/alsdec.c
@@ -1035,9 +1035,7 @@ static int decode_blocks_ind(ALSDecContext *ctx, unsigned int ra_frame,
unsigned int *js_blocks)
{
unsigned int b;
- ALSBlockData bd;
-
- memset(&bd, 0, sizeof(ALSBlockData));
+ ALSBlockData bd = { 0 };
bd.ra_block = ra_frame;
bd.const_block = ctx->const_block;
@@ -1078,9 +1076,7 @@ static int decode_blocks(ALSDecContext *ctx, unsigned int ra_frame,
ALSSpecificConfig *sconf = &ctx->sconf;
unsigned int offset = 0;
unsigned int b;
- ALSBlockData bd[2];
-
- memset(bd, 0, 2 * sizeof(ALSBlockData));
+ ALSBlockData bd[2] = { { 0 } };
bd[0].ra_block = ra_frame;
bd[0].const_block = ctx->const_block;
@@ -1346,7 +1342,7 @@ static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame)
sizeof(*ctx->raw_samples[c]) * sconf->max_order);
}
} else { // multi-channel coding
- ALSBlockData bd;
+ ALSBlockData bd = { 0 };
int b;
int *reverted_channels = ctx->reverted_channels;
unsigned int offset = 0;
@@ -1357,7 +1353,6 @@ static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame)
return -1;
}
- memset(&bd, 0, sizeof(ALSBlockData));
memset(reverted_channels, 0, sizeof(*reverted_channels) * avctx->channels);
bd.ra_block = ra_frame;
diff --git a/libavcodec/bink.c b/libavcodec/bink.c
index 4ca96e5..694a734 100644
--- a/libavcodec/bink.c
+++ b/libavcodec/bink.c
@@ -233,7 +233,7 @@ static void merge(GetBitContext *gb, uint8_t *dst, uint8_t *src, int size)
*/
static void read_tree(GetBitContext *gb, Tree *tree)
{
- uint8_t tmp1[16], tmp2[16], *in = tmp1, *out = tmp2;
+ uint8_t tmp1[16] = { 0 }, tmp2[16], *in = tmp1, *out = tmp2;
int i, t, len;
tree->vlc_num = get_bits(gb, 4);
@@ -244,7 +244,6 @@ static void read_tree(GetBitContext *gb, Tree *tree)
}
if (get_bits1(gb)) {
len = get_bits(gb, 3);
- memset(tmp1, 0, sizeof(tmp1));
for (i = 0; i <= len; i++) {
tree->syms[i] = get_bits(gb, 4);
tmp1[tree->syms[i]] = 1;
diff --git a/libavcodec/cabac_functions.h b/libavcodec/cabac_functions.h
index 226edfa..90af15c 100644
--- a/libavcodec/cabac_functions.h
+++ b/libavcodec/cabac_functions.h
@@ -47,7 +47,7 @@ static void refill(CABACContext *c){
c->low+= c->bytestream[0]<<1;
#endif
c->low -= CABAC_MASK;
- c->bytestream+= CABAC_BITS/8;
+ c->bytestream += CABAC_BITS / 8;
}
static inline void renorm_cabac_decoder_once(CABACContext *c){
@@ -74,7 +74,7 @@ static void refill2(CABACContext *c){
#endif
c->low += x<<i;
- c->bytestream+= CABAC_BITS/8;
+ c->bytestream += CABAC_BITS/8;
}
static av_always_inline int get_cabac_inline(CABACContext *c, uint8_t * const state){
diff --git a/libavcodec/cook.c b/libavcodec/cook.c
index 31b0f1f..cde2752 100644
--- a/libavcodec/cook.c
+++ b/libavcodec/cook.c
@@ -411,10 +411,10 @@ static void categorize(COOKContext *q, COOKSubpacket *p, const int *quant_index_
int *category, int *category_index)
{
int exp_idx, bias, tmpbias1, tmpbias2, bits_left, num_bits, index, v, i, j;
- int exp_index2[102];
- int exp_index1[102];
+ int exp_index2[102] = { 0 };
+ int exp_index1[102] = { 0 };
- int tmp_categorize_array[128 * 2];
+ int tmp_categorize_array[128 * 2] = { 0 };
int tmp_categorize_array1_idx = p->numvector_size;
int tmp_categorize_array2_idx = p->numvector_size;
@@ -426,10 +426,6 @@ static void categorize(COOKContext *q, COOKSubpacket *p, const int *quant_index_
//av_log(q->avctx, AV_LOG_ERROR, "bits_left = %d\n",bits_left);
}
- memset(&exp_index1, 0, sizeof(exp_index1));
- memset(&exp_index2, 0, sizeof(exp_index2));
- memset(&tmp_categorize_array, 0, sizeof(tmp_categorize_array));
-
bias = -32;
/* Estimate bias. */
@@ -649,14 +645,11 @@ static void decode_vectors(COOKContext *q, COOKSubpacket *p, int *category,
*/
static int mono_decode(COOKContext *q, COOKSubpacket *p, float *mlt_buffer)
{
- int category_index[128];
+ int category_index[128] = { 0 };
+ int category[128] = { 0 };
int quant_index_table[102];
- int category[128];
int res, i;
- memset(&category, 0, sizeof(category));
- memset(&category_index, 0, sizeof(category_index));
-
if ((res = decode_envelope(q, p, quant_index_table)) < 0)
return res;
q->num_vectors = get_bits(&q->gb, p->log2_numvector_size);
@@ -829,13 +822,12 @@ static int joint_decode(COOKContext *q, COOKSubpacket *p, float *mlt_buffer1,
float *mlt_buffer2)
{
int i, j, res;
- int decouple_tab[SUBBAND_SIZE];
+ int decouple_tab[SUBBAND_SIZE] = { 0 };
float *decode_buffer = q->decode_buffer_0;
int idx, cpl_tmp;
float f1, f2;
const float *cplscale;
- memset(decouple_tab, 0, sizeof(decouple_tab));
memset(decode_buffer, 0, sizeof(q->decode_buffer_0));
/* Make sure the buffers are zeroed out. */
diff --git a/libavcodec/dct-test.c b/libavcodec/dct-test.c
index 3a6ab96..eb2fdc6 100644
--- a/libavcodec/dct-test.c
+++ b/libavcodec/dct-test.c
@@ -74,17 +74,11 @@ struct algo {
int nonspec;
};
-#ifndef FAAN_POSTSCALE
-#define FAAN_SCALE SCALE_PERM
-#else
-#define FAAN_SCALE NO_PERM
-#endif
-
static int cpu_flags;
static const struct algo fdct_tab[] = {
{ "REF-DBL", ff_ref_fdct, NO_PERM },
- { "FAAN", ff_faandct, FAAN_SCALE },
+ { "FAAN", ff_faandct, NO_PERM },
{ "IJG-AAN-INT", ff_fdct_ifast, SCALE_PERM },
{ "IJG-LLM-INT", ff_jpeg_fdct_islow_8, NO_PERM },
diff --git a/libavcodec/dv.c b/libavcodec/dv.c
index 805ebe3..d0de545 100644
--- a/libavcodec/dv.c
+++ b/libavcodec/dv.c
@@ -323,9 +323,11 @@ av_cold int ff_dvvideo_init(AVCodecContext *avctx)
static av_cold int dvvideo_init_encoder(AVCodecContext *avctx)
{
if (!avpriv_dv_codec_profile(avctx)) {
- av_log(avctx, AV_LOG_ERROR, "Found no DV profile for %ix%i %s video\n",
+ av_log(avctx, AV_LOG_ERROR, "Found no DV profile for %ix%i %s video. "
+ "Valid DV profiles are:\n",
avctx->width, avctx->height, av_get_pix_fmt_name(avctx->pix_fmt));
- return -1;
+ ff_dv_print_profiles(avctx, AV_LOG_ERROR);
+ return AVERROR(EINVAL);
}
return ff_dvvideo_init(avctx);
diff --git a/libavcodec/dvdata.c b/libavcodec/dvdata.c
index 3dc3ae6..6a29a59 100644
--- a/libavcodec/dvdata.c
+++ b/libavcodec/dvdata.c
@@ -26,6 +26,7 @@
#include "libavutil/rational.h"
#include "libavutil/intreadwrite.h"
+#include "libavutil/pixdesc.h"
#include "avcodec.h"
#include "dvdata.h"
@@ -345,3 +346,14 @@ const DVprofile* avpriv_dv_codec_profile(AVCodecContext* codec)
return NULL;
}
+
+void ff_dv_print_profiles(void *logctx, int loglevel)
+{
+ int i;
+ for (i = 0; i < FF_ARRAY_ELEMS(dv_profiles); i++) {
+ const DVprofile *p = &dv_profiles[i];
+ av_log(logctx, loglevel, "Frame size: %dx%d; pixel format: %s, "
+ "framerate: %d/%d\n", p->width, p->height, av_get_pix_fmt_name(p->pix_fmt),
+ p->time_base.den, p->time_base.num);
+ }
+}
diff --git a/libavcodec/dvdata.h b/libavcodec/dvdata.h
index e3ce98a..9a6ac89 100644
--- a/libavcodec/dvdata.h
+++ b/libavcodec/dvdata.h
@@ -156,4 +156,9 @@ static inline void dv_calculate_mb_xy(DVVideoContext *s, DVwork_chunk *work_chun
}
}
+/**
+ * Print all allowed DV profiles into logctx at specified logging level.
+ */
+void ff_dv_print_profiles(void *logctx, int loglevel);
+
#endif /* AVCODEC_DVDATA_H */
diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c
index 8e0ee65..bff3a10 100644
--- a/libavcodec/dvdec.c
+++ b/libavcodec/dvdec.c
@@ -43,7 +43,6 @@
#include "simple_idct.h"
#include "dvdata.h"
#include "dvquant.h"
-#include "dv_tablegen.h"
typedef struct BlockInfo {
const uint32_t *factor_table;
diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c
index f4b5439..afc485b 100644
--- a/libavcodec/dvdsubdec.c
+++ b/libavcodec/dvdsubdec.c
@@ -135,7 +135,7 @@ static void guess_palette(uint32_t *rgba_palette,
{0x00, 0x80, 0xff},
{0x00, 0x55, 0xaa, 0xff},
};
- uint8_t color_used[16];
+ uint8_t color_used[16] = { 0 };
int nb_opaque_colors, i, level, j, r, g, b;
uint8_t *colormap = ctx->colormap, *alpha = ctx->alpha;
@@ -149,7 +149,6 @@ static void guess_palette(uint32_t *rgba_palette,
for(i = 0; i < 4; i++)
rgba_palette[i] = 0;
- memset(color_used, 0, 16);
nb_opaque_colors = 0;
for(i = 0; i < 4; i++) {
if (alpha[i] != 0 && !color_used[colormap[i]]) {
@@ -397,14 +396,13 @@ static int is_transp(const uint8_t *buf, int pitch, int n,
/* return 0 if empty rectangle, 1 if non empty */
static int find_smallest_bounding_rectangle(AVSubtitle *s)
{
- uint8_t transp_color[256];
+ uint8_t transp_color[256] = { 0 };
int y1, y2, x1, x2, y, w, h, i;
uint8_t *bitmap;
if (s->num_rects == 0 || s->rects == NULL || s->rects[0]->w <= 0 || s->rects[0]->h <= 0)
return 0;
- memset(transp_color, 0, 256);
for(i = 0; i < s->rects[0]->nb_colors; i++) {
if ((((uint32_t*)s->rects[0]->pict.data[1])[i] >> 24) == 0)
transp_color[i] = 1;
diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c
index 9b94b58..d866071 100644
--- a/libavcodec/dxva2.c
+++ b/libavcodec/dxva2.c
@@ -86,7 +86,7 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, MpegEncContext *s,
struct dxva_context *ctx = avctx->hwaccel_context;
unsigned buffer_count = 0;
DXVA2_DecodeBufferDesc buffer[4];
- DXVA2_DecodeExecuteParams exec;
+ DXVA2_DecodeExecuteParams exec = { 0 };
int result;
if (FAILED(IDirectXVideoDecoder_BeginFrame(ctx->decoder,
@@ -132,7 +132,6 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, MpegEncContext *s,
assert(buffer_count == 1 + (qm_size > 0) + 2);
- memset(&exec, 0, sizeof(exec));
exec.NumCompBuffers = buffer_count;
exec.pCompressedBuffers = buffer;
exec.pExtensionData = NULL;
diff --git a/libavcodec/faandct.c b/libavcodec/faandct.c
index a986f65..eaf4b65 100644
--- a/libavcodec/faandct.c
+++ b/libavcodec/faandct.c
@@ -29,11 +29,6 @@
#include "faandct.h"
#define FLOAT float
-#ifdef FAAN_POSTSCALE
-# define SCALE(x) postscale[x]
-#else
-# define SCALE(x) 1
-#endif
//numbers generated by simple c code (not as accurate as they could be)
/*
@@ -150,13 +145,13 @@ void ff_faandct(DCTELEM * data)
tmp11= tmp1 + tmp2;
tmp12= tmp1 - tmp2;
- data[8*0 + i]= lrintf(SCALE(8*0 + i) * (tmp10 + tmp11));
- data[8*4 + i]= lrintf(SCALE(8*4 + i) * (tmp10 - tmp11));
+ data[8*0 + i]= lrintf(postscale[8*0 + i] * (tmp10 + tmp11));
+ data[8*4 + i]= lrintf(postscale[8*4 + i] * (tmp10 - tmp11));
tmp12 += tmp13;
tmp12 *= A1;
- data[8*2 + i]= lrintf(SCALE(8*2 + i) * (tmp13 + tmp12));
- data[8*6 + i]= lrintf(SCALE(8*6 + i) * (tmp13 - tmp12));
+ data[8*2 + i]= lrintf(postscale[8*2 + i] * (tmp13 + tmp12));
+ data[8*6 + i]= lrintf(postscale[8*6 + i] * (tmp13 - tmp12));
tmp4 += tmp5;
tmp5 += tmp6;
@@ -175,10 +170,10 @@ void ff_faandct(DCTELEM * data)
z11= tmp7 + tmp5;
z13= tmp7 - tmp5;
- data[8*5 + i]= lrintf(SCALE(8*5 + i) * (z13 + z2));
- data[8*3 + i]= lrintf(SCALE(8*3 + i) * (z13 - z2));
- data[8*1 + i]= lrintf(SCALE(8*1 + i) * (z11 + z4));
- data[8*7 + i]= lrintf(SCALE(8*7 + i) * (z11 - z4));
+ data[8*5 + i]= lrintf(postscale[8*5 + i] * (z13 + z2));
+ data[8*3 + i]= lrintf(postscale[8*3 + i] * (z13 - z2));
+ data[8*1 + i]= lrintf(postscale[8*1 + i] * (z11 + z4));
+ data[8*7 + i]= lrintf(postscale[8*7 + i] * (z11 - z4));
}
}
@@ -208,25 +203,25 @@ void ff_faandct248(DCTELEM * data)
tmp12 = tmp1 - tmp2;
tmp13 = tmp0 - tmp3;
- data[8*0 + i] = lrintf(SCALE(8*0 + i) * (tmp10 + tmp11));
- data[8*4 + i] = lrintf(SCALE(8*4 + i) * (tmp10 - tmp11));
+ data[8*0 + i] = lrintf(postscale[8*0 + i] * (tmp10 + tmp11));
+ data[8*4 + i] = lrintf(postscale[8*4 + i] * (tmp10 - tmp11));
tmp12 += tmp13;
tmp12 *= A1;
- data[8*2 + i] = lrintf(SCALE(8*2 + i) * (tmp13 + tmp12));
- data[8*6 + i] = lrintf(SCALE(8*6 + i) * (tmp13 - tmp12));
+ data[8*2 + i] = lrintf(postscale[8*2 + i] * (tmp13 + tmp12));
+ data[8*6 + i] = lrintf(postscale[8*6 + i] * (tmp13 - tmp12));
tmp10 = tmp4 + tmp7;
tmp11 = tmp5 + tmp6;
tmp12 = tmp5 - tmp6;
tmp13 = tmp4 - tmp7;
- data[8*1 + i] = lrintf(SCALE(8*0 + i) * (tmp10 + tmp11));
- data[8*5 + i] = lrintf(SCALE(8*4 + i) * (tmp10 - tmp11));
+ data[8*1 + i] = lrintf(postscale[8*0 + i] * (tmp10 + tmp11));
+ data[8*5 + i] = lrintf(postscale[8*4 + i] * (tmp10 - tmp11));
tmp12 += tmp13;
tmp12 *= A1;
- data[8*3 + i] = lrintf(SCALE(8*2 + i) * (tmp13 + tmp12));
- data[8*7 + i] = lrintf(SCALE(8*6 + i) * (tmp13 - tmp12));
+ data[8*3 + i] = lrintf(postscale[8*2 + i] * (tmp13 + tmp12));
+ data[8*7 + i] = lrintf(postscale[8*6 + i] * (tmp13 - tmp12));
}
}
diff --git a/libavcodec/faandct.h b/libavcodec/faandct.h
index f43b62f..a12dcaf 100644
--- a/libavcodec/faandct.h
+++ b/libavcodec/faandct.h
@@ -31,8 +31,6 @@
#include "dsputil.h"
-#define FAAN_POSTSCALE
-
void ff_faandct(DCTELEM * data);
void ff_faandct248(DCTELEM * data);
diff --git a/libavcodec/flac_parser.c b/libavcodec/flac_parser.c
index 83c03c3..217461f 100644
--- a/libavcodec/flac_parser.c
+++ b/libavcodec/flac_parser.c
@@ -573,8 +573,7 @@ static int flac_parse(AVCodecParserContext *s, AVCodecContext *avctx,
av_fifo_generic_write(fpc->fifo_buf, (void*) read_start,
read_end - read_start, NULL);
} else {
- int8_t pad[MAX_FRAME_HEADER_SIZE];
- memset(pad, 0, sizeof(pad));
+ int8_t pad[MAX_FRAME_HEADER_SIZE] = { 0 };
av_fifo_generic_write(fpc->fifo_buf, (void*) pad, sizeof(pad), NULL);
}
diff --git a/libavcodec/intrax8dsp.c b/libavcodec/intrax8dsp.c
index 692e1b1..2983f3d 100644
--- a/libavcodec/intrax8dsp.c
+++ b/libavcodec/intrax8dsp.c
@@ -152,10 +152,8 @@ static void spatial_compensation_0(uint8_t *src , uint8_t *dst, int linesize){
int x,y;
unsigned int p;//power divided by 2
int a;
- uint16_t left_sum[2][8];
- uint16_t top_sum[2][8];
- memset(left_sum,0,2*8*sizeof(uint16_t));
- memset( top_sum,0,2*8*sizeof(uint16_t));
+ uint16_t left_sum[2][8] = { { 0 } };
+ uint16_t top_sum[2][8] = { { 0 } };
for(i=0;i<8;i++){
a=src[area2+7-i]<<4;
diff --git a/libavcodec/jpeglsenc.c b/libavcodec/jpeglsenc.c
index aadea77..2a333c0 100644
--- a/libavcodec/jpeglsenc.c
+++ b/libavcodec/jpeglsenc.c
@@ -210,8 +210,7 @@ static inline void ls_encode_line(JLSState *state, PutBitContext *pb, void *last
static void ls_store_lse(JLSState *state, PutBitContext *pb){
/* Test if we have default params and don't need to store LSE */
- JLSState state2;
- memset(&state2, 0, sizeof(JLSState));
+ JLSState state2 = { 0 };
state2.bpp = state->bpp;
state2.near = state->near;
ff_jpegls_reset_coding_parameters(&state2, 1);
diff --git a/libavcodec/lagarith.c b/libavcodec/lagarith.c
index ce8af64..eea5c81 100644
--- a/libavcodec/lagarith.c
+++ b/libavcodec/lagarith.c
@@ -251,21 +251,22 @@ static void lag_pred_line(LagarithContext *l, uint8_t *buf,
/* Left prediction only for first line */
L = l->dsp.add_hfyu_left_prediction(buf + 1, buf + 1,
width - 1, buf[0]);
- return;
- }
- /* Left pixel is actually prev_row[width] */
- L = buf[width - stride - 1];
- if (line == 1) {
- /* Second line, left predict first pixel, the rest of the line is median predicted
- * NOTE: In the case of RGB this pixel is top predicted */
- TL = l->avctx->pix_fmt == PIX_FMT_YUV420P ? buf[-stride] : L;
} else {
- /* Top left is 2 rows back, last pixel */
- TL = buf[width - (2 * stride) - 1];
- }
+ /* Left pixel is actually prev_row[width] */
+ L = buf[width - stride - 1];
+
+ if (line == 1) {
+ /* Second line, left predict first pixel, the rest of the line is median predicted
+ * NOTE: In the case of RGB this pixel is top predicted */
+ TL = l->avctx->pix_fmt == PIX_FMT_YUV420P ? buf[-stride] : L;
+ } else {
+ /* Top left is 2 rows back, last pixel */
+ TL = buf[width - (2 * stride) - 1];
+ }
- add_lag_median_prediction(buf, buf - stride, buf,
- width, &L, &TL);
+ add_lag_median_prediction(buf, buf - stride, buf,
+ width, &L, &TL);
+ }
}
static int lag_decode_line(LagarithContext *l, lag_rac *rac,
@@ -311,13 +312,13 @@ handle_zeros:
}
static int lag_decode_zero_run_line(LagarithContext *l, uint8_t *dst,
- const uint8_t *src, const uint8_t *srcend, int width,
- int esc_count)
+ const uint8_t *src, const uint8_t *src_end,
+ int width, int esc_count)
{
int i = 0;
int count;
uint8_t zero_run = 0;
- const uint8_t *start = src;
+ const uint8_t *src_start = src;
uint8_t mask1 = -(esc_count < 2);
uint8_t mask2 = -(esc_count < 3);
uint8_t *end = dst + (width - 2);
@@ -334,8 +335,8 @@ output_zeros:
i = 0;
while (!zero_run && dst + i < end) {
i++;
- if (i+2 >= srcend - src)
- return src - start;
+ if (i+2 >= src_end - src)
+ return AVERROR_INVALIDDATA;
zero_run =
!(src[i] | (src[i + 1] & mask1) | (src[i + 2] & mask2));
}
@@ -351,9 +352,10 @@ output_zeros:
} else {
memcpy(dst, src, i);
src += i;
+ dst += i;
}
}
- return src - start;
+ return src - src_start;
}
@@ -369,7 +371,7 @@ static int lag_decode_arith_plane(LagarithContext *l, uint8_t *dst,
int esc_count;
GetBitContext gb;
lag_rac rac;
- const uint8_t *srcend = src + src_size;
+ const uint8_t *src_end = src + src_size;
rac.avctx = l->avctx;
l->zeros = 0;
@@ -406,12 +408,16 @@ static int lag_decode_arith_plane(LagarithContext *l, uint8_t *dst,
esc_count -= 4;
if (esc_count > 0) {
/* Zero run coding only, no range coding. */
- for (i = 0; i < height; i++)
- src += lag_decode_zero_run_line(l, dst + (i * stride), src, srcend,
- width, esc_count);
+ for (i = 0; i < height; i++) {
+ int res = lag_decode_zero_run_line(l, dst + (i * stride), src,
+ src_end, width, esc_count);
+ if (res < 0)
+ return res;
+ src += res;
+ }
} else {
- if (src_size < height * width)
- return -1;
+ if (src_size < width * height)
+ return AVERROR_INVALIDDATA; // buffer not big enough
/* Plane is stored uncompressed */
for (i = 0; i < height; i++) {
memcpy(dst + (i * stride), src, width);
@@ -518,15 +524,18 @@ static int lag_decode_frame(AVCodecContext *avctx,
}
for (i = 0; i < planes; i++)
srcs[i] = l->rgb_planes + (i + 1) * l->rgb_stride * avctx->height - l->rgb_stride;
- for (i = 0; i < planes; i++) {
+ for (i = 0; i < planes; i++)
if (buf_size <= offs[i]) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Invalid frame offsets\n");
return AVERROR_INVALIDDATA;
}
+
+ for (i = 0; i < planes; i++)
lag_decode_arith_plane(l, srcs[i],
avctx->width, avctx->height,
-l->rgb_stride, buf + offs[i],
buf_size - offs[i]);
- }
dst = p->data[0];
for (i = 0; i < planes; i++)
srcs[i] = l->rgb_planes + i * l->rgb_stride * avctx->height;
@@ -563,6 +572,14 @@ static int lag_decode_frame(AVCodecContext *avctx,
return AVERROR_INVALIDDATA;
}
+ if (offset_ry >= buf_size ||
+ offset_gu >= buf_size ||
+ offset_bv >= buf_size) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Invalid frame offsets\n");
+ return AVERROR_INVALIDDATA;
+ }
+
lag_decode_arith_plane(l, p->data[0], avctx->width, avctx->height,
p->linesize[0], buf + offset_ry,
buf_size - offset_ry);
diff --git a/libavcodec/lagarithrac.c b/libavcodec/lagarithrac.c
index b3ad941..9f7bc41 100644
--- a/libavcodec/lagarithrac.c
+++ b/libavcodec/lagarithrac.c
@@ -32,15 +32,17 @@
void ff_lag_rac_init(lag_rac *l, GetBitContext *gb, int length)
{
- int i, j;
+ int i, j, left;
/* According to reference decoder "1st byte is garbage",
* however, it gets skipped by the call to align_get_bits()
*/
align_get_bits(gb);
+ left = get_bits_left(gb) >> 3;
l->bytestream_start =
l->bytestream = gb->buffer + get_bits_count(gb) / 8;
- l->bytestream_end = l->bytestream_start + get_bits_left(gb) / 8;
+ l->bytestream_end = l->bytestream_start + left;
+
l->range = 0x80;
l->low = *l->bytestream >> 1;
l->hash_shift = FFMAX(l->scale - 8, 0);
diff --git a/libavcodec/libxvid_rc.c b/libavcodec/libxvid_rc.c
index d65e4f2..d18fc86 100644
--- a/libavcodec/libxvid_rc.c
+++ b/libavcodec/libxvid_rc.c
@@ -36,8 +36,8 @@ extern unsigned int xvid_debug;
int ff_xvid_rate_control_init(MpegEncContext *s){
char *tmp_name;
int fd, i;
- xvid_plg_create_t xvid_plg_create;
- xvid_plugin_2pass2_t xvid_2pass2;
+ xvid_plg_create_t xvid_plg_create = { 0 };
+ xvid_plugin_2pass2_t xvid_2pass2 = { 0 };
//xvid_debug=-1;
@@ -67,7 +67,6 @@ int ff_xvid_rate_control_init(MpegEncContext *s){
close(fd);
- memset(&xvid_2pass2, 0, sizeof(xvid_2pass2));
xvid_2pass2.version= XVID_MAKE_VERSION(1,1,0);
xvid_2pass2.filename= tmp_name;
xvid_2pass2.bitrate= s->avctx->bit_rate;
@@ -75,7 +74,6 @@ int ff_xvid_rate_control_init(MpegEncContext *s){
xvid_2pass2.vbv_maxrate= s->avctx->rc_max_rate;
xvid_2pass2.vbv_initial= s->avctx->rc_initial_buffer_occupancy;
- memset(&xvid_plg_create, 0, sizeof(xvid_plg_create));
xvid_plg_create.version= XVID_MAKE_VERSION(1,1,0);
xvid_plg_create.fbase= s->avctx->time_base.den;
xvid_plg_create.fincr= s->avctx->time_base.num;
@@ -89,9 +87,8 @@ int ff_xvid_rate_control_init(MpegEncContext *s){
}
float ff_xvid_rate_estimate_qscale(MpegEncContext *s, int dry_run){
- xvid_plg_data_t xvid_plg_data;
+ xvid_plg_data_t xvid_plg_data = { 0 };
- memset(&xvid_plg_data, 0, sizeof(xvid_plg_data));
xvid_plg_data.version= XVID_MAKE_VERSION(1,1,0);
xvid_plg_data.width = s->width;
xvid_plg_data.height= s->height;
diff --git a/libavcodec/libxvidff.c b/libavcodec/libxvidff.c
index 3bca945..3ec75fe 100644
--- a/libavcodec/libxvidff.c
+++ b/libavcodec/libxvidff.c
@@ -94,11 +94,11 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx) {
uint16_t *intra, *inter;
int fd;
- xvid_plugin_single_t single;
- struct xvid_ff_pass1 rc2pass1;
- xvid_plugin_2pass2_t rc2pass2;
- xvid_gbl_init_t xvid_gbl_init;
- xvid_enc_create_t xvid_enc_create;
+ xvid_plugin_single_t single = { 0 };
+ struct xvid_ff_pass1 rc2pass1 = { 0 };
+ xvid_plugin_2pass2_t rc2pass2 = { 0 };
+ xvid_gbl_init_t xvid_gbl_init = { 0 };
+ xvid_enc_create_t xvid_enc_create = { 0 };
xvid_enc_plugin_t plugins[7];
/* Bring in VOP flags from ffmpeg command-line */
@@ -168,7 +168,6 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx) {
x->me_flags |= XVID_ME_QUARTERPELREFINE8;
}
- memset(&xvid_gbl_init, 0, sizeof(xvid_gbl_init));
xvid_gbl_init.version = XVID_VERSION;
xvid_gbl_init.debug = 0;
@@ -189,7 +188,6 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx) {
xvid_global(NULL, XVID_GBL_INIT, &xvid_gbl_init, NULL);
/* Create the encoder reference */
- memset(&xvid_enc_create, 0, sizeof(xvid_enc_create));
xvid_enc_create.version = XVID_VERSION;
/* Store the desired frame size */
@@ -214,7 +212,6 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx) {
x->twopassfile = NULL;
if( xvid_flags & CODEC_FLAG_PASS1 ) {
- memset(&rc2pass1, 0, sizeof(struct xvid_ff_pass1));
rc2pass1.version = XVID_VERSION;
rc2pass1.context = x;
x->twopassbuffer = av_malloc(BUFFER_SIZE);
@@ -230,7 +227,6 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx) {
plugins[xvid_enc_create.num_plugins].param = &rc2pass1;
xvid_enc_create.num_plugins++;
} else if( xvid_flags & CODEC_FLAG_PASS2 ) {
- memset(&rc2pass2, 0, sizeof(xvid_plugin_2pass2_t));
rc2pass2.version = XVID_VERSION;
rc2pass2.bitrate = avctx->bit_rate;
@@ -262,7 +258,6 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx) {
xvid_enc_create.num_plugins++;
} else if( !(xvid_flags & CODEC_FLAG_QSCALE) ) {
/* Single Pass Bitrate Control! */
- memset(&single, 0, sizeof(xvid_plugin_single_t));
single.version = XVID_VERSION;
single.bitrate = avctx->bit_rate;
@@ -382,16 +377,14 @@ static int xvid_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
int mb_width = (avctx->width + 15) / 16;
int mb_height = (avctx->height + 15) / 16;
- xvid_enc_frame_t xvid_enc_frame;
- xvid_enc_stats_t xvid_enc_stats;
+ xvid_enc_frame_t xvid_enc_frame = { 0 };
+ xvid_enc_stats_t xvid_enc_stats = { 0 };
if ((ret = ff_alloc_packet2(avctx, pkt, mb_width*mb_height*MAX_MB_BYTES + FF_MIN_BUFFER_SIZE)) < 0)
return ret;
/* Start setting up the frame */
- memset(&xvid_enc_frame, 0, sizeof(xvid_enc_frame));
xvid_enc_frame.version = XVID_VERSION;
- memset(&xvid_enc_stats, 0, sizeof(xvid_enc_stats));
xvid_enc_stats.version = XVID_VERSION;
*p = *picture;
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 70798fd..d369518 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -47,14 +47,13 @@ static int build_vlc(VLC *vlc, const uint8_t *bits_table,
const uint8_t *val_table, int nb_codes,
int use_static, int is_ac)
{
- uint8_t huff_size[256];
+ uint8_t huff_size[256] = { 0 };
uint16_t huff_code[256];
uint16_t huff_sym[256];
int i;
assert(nb_codes <= 256);
- memset(huff_size, 0, sizeof(huff_size));
ff_mjpeg_build_huffman_codes(huff_size, huff_code, bits_table, val_table);
for (i = 0; i < 256; i++)
diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c
index ad63952..2708a1e 100644
--- a/libavcodec/motion_est.c
+++ b/libavcodec/motion_est.c
@@ -1435,9 +1435,8 @@ static inline int bidir_refine(MpegEncContext * s, int mb_x, int mb_y)
#define HASH(fx,fy,bx,by) ((fx)+17*(fy)+63*(bx)+117*(by))
#define HASH8(fx,fy,bx,by) ((uint8_t)HASH(fx,fy,bx,by))
int hashidx= HASH(motion_fx,motion_fy, motion_bx, motion_by);
- uint8_t map[256];
+ uint8_t map[256] = { 0 };
- memset(map,0,sizeof(map));
map[hashidx&255] = 1;
fbmin= check_bidir_mv(s, motion_fx, motion_fy,
diff --git a/libavcodec/mpegaudiodec.c b/libavcodec/mpegaudiodec.c
index 51db72a..c2d8dd5 100644
--- a/libavcodec/mpegaudiodec.c
+++ b/libavcodec/mpegaudiodec.c
@@ -304,11 +304,8 @@ static av_cold void decode_init_static(void)
for (i = 1; i < 16; i++) {
const HuffTable *h = &mpa_huff_tables[i];
int xsize, x, y;
- uint8_t tmp_bits [512];
- uint16_t tmp_codes[512];
-
- memset(tmp_bits , 0, sizeof(tmp_bits ));
- memset(tmp_codes, 0, sizeof(tmp_codes));
+ uint8_t tmp_bits [512] = { 0 };
+ uint16_t tmp_codes[512] = { 0 };
xsize = h->xsize;
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 79ebaf0..17a2512 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -80,11 +80,8 @@ void ff_convert_matrix(DSPContext *dsp, int (*qmat)[64],
for (qscale = qmin; qscale <= qmax; qscale++) {
int i;
if (dsp->fdct == ff_jpeg_fdct_islow_8 ||
- dsp->fdct == ff_jpeg_fdct_islow_10
-#ifdef FAAN_POSTSCALE
- || dsp->fdct == ff_faandct
-#endif
- ) {
+ dsp->fdct == ff_jpeg_fdct_islow_10 ||
+ dsp->fdct == ff_faandct) {
for (i = 0; i < 64; i++) {
const int j = dsp->idct_permutation[i];
/* 16 <= qscale * quant_matrix[i] <= 7905
@@ -96,11 +93,7 @@ void ff_convert_matrix(DSPContext *dsp, int (*qmat)[64],
qmat[qscale][i] = (int)((UINT64_C(1) << QMAT_SHIFT) /
(qscale * quant_matrix[j]));
}
- } else if (dsp->fdct == ff_fdct_ifast
-#ifndef FAAN_POSTSCALE
- || dsp->fdct == ff_faandct
-#endif
- ) {
+ } else if (dsp->fdct == ff_fdct_ifast) {
for (i = 0; i < 64; i++) {
const int j = dsp->idct_permutation[i];
/* 16 <= qscale * quant_matrix[i] <= 7905
@@ -138,11 +131,7 @@ void ff_convert_matrix(DSPContext *dsp, int (*qmat)[64],
for (i = intra; i < 64; i++) {
int64_t max = 8191;
- if (dsp->fdct == ff_fdct_ifast
-#ifndef FAAN_POSTSCALE
- || dsp->fdct == ff_faandct
-#endif
- ) {
+ if (dsp->fdct == ff_fdct_ifast) {
max = (8191LL * ff_aanscales[i]) >> 14;
}
while (((max * qmat[qscale][i]) >> shift) > INT_MAX) {
@@ -3516,11 +3505,7 @@ static int dct_quantize_trellis_c(MpegEncContext *s,
int dct_coeff= FFABS(block[ scantable[i] ]);
int best_score=256*256*256*120;
- if ( s->dsp.fdct == ff_fdct_ifast
-#ifndef FAAN_POSTSCALE
- || s->dsp.fdct == ff_faandct
-#endif
- )
+ if (s->dsp.fdct == ff_fdct_ifast)
dct_coeff= (dct_coeff*ff_inv_aanscales[ scantable[i] ]) >> 12;
zero_distortion= dct_coeff*dct_coeff;
diff --git a/libavcodec/ra144enc.c b/libavcodec/ra144enc.c
index 9d74380..6c08a70 100644
--- a/libavcodec/ra144enc.c
+++ b/libavcodec/ra144enc.c
@@ -342,7 +342,7 @@ static void ra144_encode_subblock(RA144Context *ractx,
const int16_t *lpc_coefs, unsigned int rms,
PutBitContext *pb)
{
- float data[BLOCKSIZE], work[LPC_ORDER + BLOCKSIZE];
+ float data[BLOCKSIZE] = { 0 }, work[LPC_ORDER + BLOCKSIZE];
float coefs[LPC_ORDER];
float zero[BLOCKSIZE], cba[BLOCKSIZE], cb1[BLOCKSIZE], cb2[BLOCKSIZE];
int16_t cba_vect[BLOCKSIZE];
@@ -360,7 +360,6 @@ static void ra144_encode_subblock(RA144Context *ractx,
* Calculate the zero-input response of the LPC filter and subtract it from
* input data.
*/
- memset(data, 0, sizeof(data));
ff_celp_lp_synthesis_filterf(work + LPC_ORDER, coefs, data, BLOCKSIZE,
LPC_ORDER);
for (i = 0; i < BLOCKSIZE; i++) {
diff --git a/libavcodec/rangecoder.c b/libavcodec/rangecoder.c
index 04c2738..ef9a090 100644
--- a/libavcodec/rangecoder.c
+++ b/libavcodec/rangecoder.c
@@ -119,7 +119,7 @@ int main(void){
uint8_t b[9*SIZE];
uint8_t r[9*SIZE];
int i;
- uint8_t state[10]= {0};
+ uint8_t state[10];
AVLFG prng;
av_lfg_init(&prng, 1);
diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c
index 235b3ed..afde77b 100644
--- a/libavcodec/rv34.c
+++ b/libavcodec/rv34.c
@@ -554,7 +554,7 @@ static void rv34_pred_mv_b(RV34DecContext *r, int block_type, int dir)
MpegEncContext *s = &r->s;
int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
int mv_pos = s->mb_x * 2 + s->mb_y * 2 * s->b8_stride;
- int A[2], B[2], C[2];
+ int A[2] = { 0 }, B[2] = { 0 }, C[2] = { 0 };
int has_A = 0, has_B = 0, has_C = 0;
int mx, my;
int i, j;
@@ -562,9 +562,6 @@ static void rv34_pred_mv_b(RV34DecContext *r, int block_type, int dir)
const int mask = dir ? MB_TYPE_L1 : MB_TYPE_L0;
int type = cur_pic->f.mb_type[mb_pos];
- memset(A, 0, sizeof(A));
- memset(B, 0, sizeof(B));
- memset(C, 0, sizeof(C));
if((r->avail_cache[6-1] & type) & mask){
A[0] = cur_pic->f.motion_val[dir][mv_pos - 1][0];
A[1] = cur_pic->f.motion_val[dir][mv_pos - 1][1];
diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c
index 04994b2..d2f9df0 100644
--- a/libavcodec/smacker.c
+++ b/libavcodec/smacker.c
@@ -180,7 +180,7 @@ static int smacker_decode_header_tree(SmackVContext *smk, GetBitContext *gb, int
int res;
HuffContext huff;
HuffContext tmp1, tmp2;
- VLC vlc[2];
+ VLC vlc[2] = { { 0 } };
int escapes[3];
DBCtx ctx;
int err = 0;
@@ -204,9 +204,6 @@ static int smacker_decode_header_tree(SmackVContext *smk, GetBitContext *gb, int
tmp2.lengths = av_mallocz(256 * sizeof(int));
tmp2.values = av_mallocz(256 * sizeof(int));
- memset(&vlc[0], 0, sizeof(VLC));
- memset(&vlc[1], 0, sizeof(VLC));
-
if(get_bits1(gb)) {
smacker_decode_tree(gb, &tmp1, 0, 0);
skip_bits1(gb);
@@ -597,8 +594,8 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data,
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
GetBitContext gb;
- HuffContext h[4];
- VLC vlc[4];
+ HuffContext h[4] = { { 0 } };
+ VLC vlc[4] = { { 0 } };
int16_t *samples;
uint8_t *samples8;
int val;
@@ -641,8 +638,6 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data,
samples = (int16_t *)s->frame.data[0];
samples8 = s->frame.data[0];
- memset(vlc, 0, sizeof(VLC) * 4);
- memset(h, 0, sizeof(HuffContext) * 4);
// Initialize
for(i = 0; i < (1 << (bits + stereo)); i++) {
h[i].length = 256;
diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 28bae61..e2ea1d3 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -82,10 +82,9 @@ static unsigned tget(const uint8_t **p, int type, int le) {
#if CONFIG_ZLIB
static int tiff_uncompress(uint8_t *dst, unsigned long *len, const uint8_t *src, int size)
{
- z_stream zstream;
+ z_stream zstream = { 0 };
int zret;
- memset(&zstream, 0, sizeof(zstream));
zstream.next_in = src;
zstream.avail_in = size;
zstream.next_out = dst;
diff --git a/libavcodec/truemotion1.c b/libavcodec/truemotion1.c
index 767eced..334d6bd 100644
--- a/libavcodec/truemotion1.c
+++ b/libavcodec/truemotion1.c
@@ -310,7 +310,7 @@ static int truemotion1_decode_header(TrueMotion1Context *s)
int width_shift = 0;
int new_pix_fmt;
struct frame_header header;
- uint8_t header_buffer[128]; /* logical maximum size of the header */
+ uint8_t header_buffer[128] = { 0 }; /* logical maximum size of the header */
const uint8_t *sel_vector_table;
header.header_size = ((s->buf[0] >> 5) | (s->buf[0] << 3)) & 0x7f;
@@ -321,7 +321,6 @@ static int truemotion1_decode_header(TrueMotion1Context *s)
}
/* unscramble the header bytes with a XOR operation */
- memset(header_buffer, 0, 128);
for (i = 1; i < header.header_size; i++)
header_buffer[i - 1] = s->buf[i] ^ s->buf[i + 1];
diff --git a/libavcodec/wmalosslessdec.c b/libavcodec/wmalosslessdec.c
index af676f1..4f17a18 100644
--- a/libavcodec/wmalosslessdec.c
+++ b/libavcodec/wmalosslessdec.c
@@ -903,6 +903,7 @@ static int decode_subframe(WmallDecodeCtx *s)
} else if (!s->cdlms[0][0].order) {
av_log(s->avctx, AV_LOG_DEBUG,
"Waiting for seekable tile\n");
+ s->frame.nb_samples = 0;
return -1;
}
@@ -1265,6 +1266,17 @@ static int decode_packet(AVCodecContext *avctx, void *data, int *got_frame_ptr,
return (s->packet_loss) ? AVERROR_INVALIDDATA : get_bits_count(gb) >> 3;
}
+static void flush(AVCodecContext *avctx)
+{
+ WmallDecodeCtx *s = avctx->priv_data;
+ s->packet_loss = 1;
+ s->packet_done = 0;
+ s->num_saved_bits = 0;
+ s->frame_offset = 0;
+ s->next_packet_start = 0;
+ s->cdlms[0][0].order = 0;
+ s->frame.nb_samples = 0;
+}
AVCodec ff_wmalossless_decoder = {
.name = "wmalossless",
@@ -1273,6 +1285,7 @@ AVCodec ff_wmalossless_decoder = {
.priv_data_size = sizeof(WmallDecodeCtx),
.init = decode_init,
.decode = decode_packet,
+ .flush = flush,
.capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DR1 | CODEC_CAP_DELAY,
.long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio Lossless"),
};
diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c
index 5440d64..287c598 100644
--- a/libavcodec/wmaprodec.c
+++ b/libavcodec/wmaprodec.c
@@ -521,7 +521,7 @@ static int decode_subframe_length(WMAProDecodeCtx *s, int offset)
*/
static int decode_tilehdr(WMAProDecodeCtx *s)
{
- uint16_t num_samples[WMAPRO_MAX_CHANNELS]; /**< sum of samples for all currently known subframes of a channel */
+ uint16_t num_samples[WMAPRO_MAX_CHANNELS] = { 0 };/**< sum of samples for all currently known subframes of a channel */
uint8_t contains_subframe[WMAPRO_MAX_CHANNELS]; /**< flag indicating if a channel contains the current subframe */
int channels_for_cur_subframe = s->num_channels; /**< number of channels that contain the current subframe */
int fixed_channel_layout = 0; /**< flag indicating that all channels use the same subframe offsets and sizes */
@@ -538,8 +538,6 @@ static int decode_tilehdr(WMAProDecodeCtx *s)
for (c = 0; c < s->num_channels; c++)
s->channel[c].num_subframes = 0;
- memset(num_samples, 0, sizeof(num_samples));
-
if (s->max_num_subframes == 1 || get_bits1(&s->gb))
fixed_channel_layout = 1;
diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c
index 66c0ce4..48b7901 100644
--- a/libavcodec/wmavoice.c
+++ b/libavcodec/wmavoice.c
@@ -318,10 +318,9 @@ static av_cold int decode_vbmtree(GetBitContext *gb, int8_t vbm_tree[25])
0x0ffc, 0x0ffd, 0x0ffe, // 1111111111+00/01/10
0x3ffc, 0x3ffd, 0x3ffe, 0x3fff // 111111111111+xx
};
- int cntr[8], n, res;
+ int cntr[8] = { 0 }, n, res;
memset(vbm_tree, 0xff, sizeof(vbm_tree[0]) * 25);
- memset(cntr, 0, sizeof(cntr));
for (n = 0; n < 17; n++) {
res = get_bits(gb, 3);
if (cntr[res] > 3) // should be >= 3 + (res == 7))
diff --git a/libavcodec/x86/cabac.h b/libavcodec/x86/cabac.h
index 2bb0be6..0c4419b 100644
--- a/libavcodec/x86/cabac.h
+++ b/libavcodec/x86/cabac.h
@@ -27,7 +27,7 @@
#include "config.h"
#if HAVE_FAST_CMOV
-#define BRANCHLESS_GET_CABAC_UPDATE(ret, statep, low, lowword, range, tmp)\
+#define BRANCHLESS_GET_CABAC_UPDATE(ret, statep, low, range, tmp)\
"mov "tmp" , %%ecx \n\t"\
"shl $17 , "tmp" \n\t"\
"cmp "low" , "tmp" \n\t"\
@@ -37,7 +37,7 @@
"xor %%ecx , "ret" \n\t"\
"sub "tmp" , "low" \n\t"
#else /* HAVE_FAST_CMOV */
-#define BRANCHLESS_GET_CABAC_UPDATE(ret, statep, low, lowword, range, tmp)\
+#define BRANCHLESS_GET_CABAC_UPDATE(ret, statep, low, range, tmp)\
"mov "tmp" , %%ecx \n\t"\
"shl $17 , "tmp" \n\t"\
"sub "low" , "tmp" \n\t"\
@@ -51,20 +51,20 @@
"xor "tmp" , "ret" \n\t"
#endif /* HAVE_FAST_CMOV */
-#define BRANCHLESS_GET_CABAC(ret, statep, low, lowword, range, tmp, tmpbyte, byte) \
+#define BRANCHLESS_GET_CABAC(ret, statep, low, lowword, range, tmp, tmpbyte, byte, end) \
"movzbl "statep" , "ret" \n\t"\
"mov "range" , "tmp" \n\t"\
"and $0xC0 , "range" \n\t"\
"movzbl "MANGLE(ff_h264_lps_range)"("ret", "range", 2), "range" \n\t"\
"sub "range" , "tmp" \n\t"\
- BRANCHLESS_GET_CABAC_UPDATE(ret, statep, low, lowword, range, tmp) \
+ BRANCHLESS_GET_CABAC_UPDATE(ret, statep, low, range, tmp) \
"movzbl " MANGLE(ff_h264_norm_shift) "("range"), %%ecx \n\t"\
"shl %%cl , "range" \n\t"\
"movzbl "MANGLE(ff_h264_mlps_state)"+128("ret"), "tmp" \n\t"\
"shl %%cl , "low" \n\t"\
"mov "tmpbyte" , "statep" \n\t"\
"test "lowword" , "lowword" \n\t"\
- " jnz 1f \n\t"\
+ " jnz 2f \n\t"\
"mov "byte" , %%"REG_c" \n\t"\
"add"OPSIZE" $2 , "byte" \n\t"\
"movzwl (%%"REG_c") , "tmp" \n\t"\
@@ -79,7 +79,7 @@
"add $7 , %%ecx \n\t"\
"shl %%cl , "tmp" \n\t"\
"add "tmp" , "low" \n\t"\
- "1: \n\t"
+ "2: \n\t"
#if HAVE_7REGS && !defined(BROKEN_RELOCATIONS) && !(defined(__i386) && defined(__clang__) && (__clang_major__<2 || (__clang_major__==2 && __clang_minor__<10)))\
@@ -91,11 +91,13 @@ static av_always_inline int get_cabac_inline_x86(CABACContext *c,
int bit, tmp;
__asm__ volatile(
- BRANCHLESS_GET_CABAC("%0", "(%5)", "%1", "%w1", "%2",
- "%3", "%b3", "%4")
- :"=&r"(bit), "+&r"(c->low), "+&r"(c->range), "=&q"(tmp),
- "+m"(c->bytestream)
- :"r"(state)
+ BRANCHLESS_GET_CABAC("%0", "(%4)", "%1", "%w1",
+ "%2", "%3", "%b3",
+ "%a6(%5)", "%a7(%5)")
+ : "=&r"(bit), "+&r"(c->low), "+&r"(c->range), "=&q"(tmp)
+ : "r"(state), "r"(c),
+ "i"(offsetof(CABACContext, bytestream)),
+ "i"(offsetof(CABACContext, bytestream_end))
: "%"REG_c, "memory"
);
return bit & 1;
@@ -107,32 +109,36 @@ static av_always_inline int get_cabac_bypass_sign_x86(CABACContext *c, int val)
{
x86_reg tmp;
__asm__ volatile(
- "movl %4, %k1 \n\t"
- "movl %2, %%eax \n\t"
- "shl $17, %k1 \n\t"
- "add %%eax, %%eax \n\t"
- "sub %k1, %%eax \n\t"
- "cltd \n\t"
- "and %%edx, %k1 \n\t"
- "add %k1, %%eax \n\t"
- "xor %%edx, %%ecx \n\t"
- "sub %%edx, %%ecx \n\t"
- "test %%ax, %%ax \n\t"
- " jnz 1f \n\t"
- "mov %3, %1 \n\t"
- "subl $0xFFFF, %%eax \n\t"
- "movzwl (%1), %%edx \n\t"
- "bswap %%edx \n\t"
- "shrl $15, %%edx \n\t"
- "add $2, %1 \n\t"
- "addl %%edx, %%eax \n\t"
- "mov %1, %3 \n\t"
- "1: \n\t"
- "movl %%eax, %2 \n\t"
+ "movl %a6(%2), %k1 \n\t"
+ "movl %a3(%2), %%eax \n\t"
+ "shl $17, %k1 \n\t"
+ "add %%eax, %%eax \n\t"
+ "sub %k1, %%eax \n\t"
+ "cltd \n\t"
+ "and %%edx, %k1 \n\t"
+ "add %k1, %%eax \n\t"
+ "xor %%edx, %%ecx \n\t"
+ "sub %%edx, %%ecx \n\t"
+ "test %%ax, %%ax \n\t"
+ "jnz 1f \n\t"
+ "mov %a4(%2), %1 \n\t"
+ "subl $0xFFFF, %%eax \n\t"
+ "movzwl (%1), %%edx \n\t"
+ "bswap %%edx \n\t"
+ "shrl $15, %%edx \n\t"
+ "add $2, %1 \n\t"
+ "addl %%edx, %%eax \n\t"
+ "mov %1, %a4(%2) \n\t"
+ "1: \n\t"
+ "movl %%eax, %a3(%2) \n\t"
- :"+c"(val), "=&r"(tmp), "+m"(c->low), "+m"(c->bytestream)
- :"m"(c->range)
- : "%eax", "%edx"
+ : "+c"(val), "=&r"(tmp)
+ : "r"(c),
+ "i"(offsetof(CABACContext, low)),
+ "i"(offsetof(CABACContext, bytestream)),
+ "i"(offsetof(CABACContext, bytestream_end)),
+ "i"(offsetof(CABACContext, range))
+ : "%eax", "%edx", "memory"
);
return val;
}
diff --git a/libavcodec/x86/h264_i386.h b/libavcodec/x86/h264_i386.h
index 510f726..6aa2d07 100644
--- a/libavcodec/x86/h264_i386.h
+++ b/libavcodec/x86/h264_i386.h
@@ -46,17 +46,19 @@ static int decode_significance_x86(CABACContext *c, int max_coeff,
int bit;
x86_reg coeff_count;
__asm__ volatile(
- "2: \n\t"
+ "3: \n\t"
- BRANCHLESS_GET_CABAC("%4", "(%1)", "%3",
- "%w3", "%5", "%k0", "%b0", "%6")
+ BRANCHLESS_GET_CABAC("%4", "(%1)", "%3", "%w3",
+ "%5", "%k0", "%b0",
+ "%a11(%6)", "%a12(%6)")
"test $1, %4 \n\t"
- " jz 3f \n\t"
+ " jz 4f \n\t"
"add %10, %1 \n\t"
- BRANCHLESS_GET_CABAC("%4", "(%1)", "%3",
- "%w3", "%5", "%k0", "%b0", "%6")
+ BRANCHLESS_GET_CABAC("%4", "(%1)", "%3", "%w3",
+ "%5", "%k0", "%b0",
+ "%a11(%6)", "%a12(%6)")
"sub %10, %1 \n\t"
"mov %2, %0 \n\t"
@@ -65,25 +67,26 @@ static int decode_significance_x86(CABACContext *c, int max_coeff,
"movl %%ecx, (%0) \n\t"
"test $1, %4 \n\t"
- " jnz 4f \n\t"
+ " jnz 5f \n\t"
"add"OPSIZE" $4, %2 \n\t"
- "3: \n\t"
+ "4: \n\t"
"add $1, %1 \n\t"
"cmp %8, %1 \n\t"
- " jb 2b \n\t"
+ " jb 3b \n\t"
"mov %2, %0 \n\t"
"movl %7, %%ecx \n\t"
"add %1, %%"REG_c" \n\t"
"movl %%ecx, (%0) \n\t"
- "4: \n\t"
+ "5: \n\t"
"add %9, %k0 \n\t"
"shr $2, %k0 \n\t"
- :"=&q"(coeff_count), "+r"(significant_coeff_ctx_base), "+m"(index),
- "+&r"(c->low), "=&r"(bit), "+&r"(c->range),
- "+m"(c->bytestream)
- :"m"(minusstart), "m"(end), "m"(minusindex), "m"(last_off)
+ : "=&q"(coeff_count), "+r"(significant_coeff_ctx_base), "+m"(index),
+ "+&r"(c->low), "=&r"(bit), "+&r"(c->range)
+ : "r"(c), "m"(minusstart), "m"(end), "m"(minusindex), "m"(last_off),
+ "i"(offsetof(CABACContext, bytestream)),
+ "i"(offsetof(CABACContext, bytestream_end))
: "%"REG_c, "memory"
);
return coeff_count;
@@ -99,47 +102,52 @@ static int decode_significance_8x8_x86(CABACContext *c,
x86_reg state;
__asm__ volatile(
"mov %1, %6 \n\t"
- "2: \n\t"
+ "3: \n\t"
"mov %10, %0 \n\t"
"movzbl (%0, %6), %k6 \n\t"
"add %9, %6 \n\t"
- BRANCHLESS_GET_CABAC("%4", "(%6)", "%3",
- "%w3", "%5", "%k0", "%b0", "%7")
+ BRANCHLESS_GET_CABAC("%4", "(%6)", "%3", "%w3",
+ "%5", "%k0", "%b0",
+ "%a12(%7)", "%a13(%7)")
"mov %1, %k6 \n\t"
"test $1, %4 \n\t"
- " jz 3f \n\t"
+ " jz 4f \n\t"
"movzbl "MANGLE(last_coeff_flag_offset_8x8)"(%k6), %k6\n\t"
"add %11, %6 \n\t"
- BRANCHLESS_GET_CABAC("%4", "(%6)", "%3",
- "%w3", "%5", "%k0", "%b0", "%7")
+ BRANCHLESS_GET_CABAC("%4", "(%6)", "%3", "%w3",
+ "%5", "%k0", "%b0",
+ "%a12(%7)", "%a13(%7)")
"mov %2, %0 \n\t"
"mov %1, %k6 \n\t"
"movl %k6, (%0) \n\t"
"test $1, %4 \n\t"
- " jnz 4f \n\t"
+ " jnz 5f \n\t"
"add"OPSIZE" $4, %2 \n\t"
- "3: \n\t"
+ "4: \n\t"
"addl $1, %k6 \n\t"
"mov %k6, %1 \n\t"
"cmpl $63, %k6 \n\t"
- " jb 2b \n\t"
+ " jb 3b \n\t"
"mov %2, %0 \n\t"
"movl %k6, (%0) \n\t"
- "4: \n\t"
+ "5: \n\t"
"addl %8, %k0 \n\t"
"shr $2, %k0 \n\t"
- :"=&q"(coeff_count),"+m"(last), "+m"(index), "+&r"(c->low), "=&r"(bit),
- "+&r"(c->range), "=&r"(state), "+m"(c->bytestream)
- :"m"(minusindex), "m"(significant_coeff_ctx_base), "m"(sig_off), "m"(last_coeff_ctx_base)
+ : "=&q"(coeff_count), "+m"(last), "+m"(index), "+&r"(c->low),
+ "=&r"(bit), "+&r"(c->range), "=&r"(state)
+ : "r"(c), "m"(minusindex), "m"(significant_coeff_ctx_base),
+ "m"(sig_off), "m"(last_coeff_ctx_base),
+ "i"(offsetof(CABACContext, bytestream)),
+ "i"(offsetof(CABACContext, bytestream_end))
: "%"REG_c, "memory"
);
return coeff_count;
OpenPOWER on IntegriCloud