summaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/arm/ac3dsp_armv6.S15
-rw-r--r--libavcodec/bethsoftvideo.c10
-rw-r--r--libavcodec/internal.h1
-rw-r--r--libavcodec/libx264.c10
-rw-r--r--libavcodec/mpc.h2
-rw-r--r--libavcodec/mpc7.c46
-rw-r--r--libavcodec/pcm.c1
-rw-r--r--libavcodec/ra144enc.c2
-rw-r--r--libavcodec/utils.c4
-rw-r--r--libavcodec/vorbis.c19
-rw-r--r--libavcodec/vorbisdec.c10
-rw-r--r--libavcodec/x86/Makefile1
-rw-r--r--libavcodec/x86/dsputil_yasm.asm2
-rw-r--r--libavcodec/x86/w64xmmtest.c80
14 files changed, 148 insertions, 55 deletions
diff --git a/libavcodec/arm/ac3dsp_armv6.S b/libavcodec/arm/ac3dsp_armv6.S
index b6aee86..df8bfba 100644
--- a/libavcodec/arm/ac3dsp_armv6.S
+++ b/libavcodec/arm/ac3dsp_armv6.S
@@ -34,24 +34,23 @@ function ff_ac3_bit_alloc_calc_bap_armv6, export=1
add r0, r0, r4, lsl #1 @ mask + band
add r4, lr, r4
add r7, r7, r2 @ bap + start
- ldrb r10, [r4], #1
1:
ldrsh r9, [r0], #2 @ mask[band]
mov r8, #0xff0
sub r9, r9, r12 @ - snr_offset
- mov r11, r10
- ldrb r10, [r4], #1 @ band_start_tab[band++]
+ ldrb r10, [r4, #1]! @ band_start_tab[++band]
subs r9, r9, r5 @ - floor
it lt
movlt r9, #0
cmp r10, r3 @ - end
and r9, r9, r8, lsl #1 @ & 0x1fe0
ite gt
- subgt r8, r3, r11
- suble r8, r10, r11
+ subgt r8, r3, r2
+ suble r8, r10, r2
+ mov r2, r10
add r9, r9, r5 @ + floor => m
tst r8, #1
- add r2, r7, r8
+ add r11, r7, r8
bne 3f
b 5f
2:
@@ -65,9 +64,9 @@ function ff_ac3_bit_alloc_calc_bap_armv6, export=1
ldrb lr, [r6, lr]
strb r8, [r7], #1 @ bap[bin]
strb lr, [r7], #1
-5: cmp r7, r2
+5: cmp r7, r11
blo 2b
- cmp r3, r11
+ cmp r3, r10
bgt 1b
pop {r4-r11,pc}
3:
diff --git a/libavcodec/bethsoftvideo.c b/libavcodec/bethsoftvideo.c
index d80ac16..d85783b 100644
--- a/libavcodec/bethsoftvideo.c
+++ b/libavcodec/bethsoftvideo.c
@@ -61,7 +61,7 @@ static int set_palette(BethsoftvidContext *ctx)
palette[a] |= palette[a] >> 6 & 0x30303;
}
ctx->frame.palette_has_changed = 1;
- return 256*3;
+ return 0;
}
static int bethsoftvid_decode_frame(AVCodecContext *avctx,
@@ -88,7 +88,13 @@ static int bethsoftvid_decode_frame(AVCodecContext *avctx,
switch(block_type = bytestream2_get_byte(&vid->g)){
case PALETTE_BLOCK: {
- return set_palette(vid);
+ int ret;
+ *data_size = 0;
+ if ((ret = set_palette(vid)) < 0) {
+ av_log(avctx, AV_LOG_ERROR, "error reading palette\n");
+ return ret;
+ }
+ return bytestream2_tell(&vid->g);
}
case VIDEO_YOFF_P_FRAME:
yoffset = bytestream2_get_le16(&vid->g);
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index 72a8944..b7d4a6e 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -130,6 +130,7 @@ int avpriv_unlock_avformat(void);
* If avpkt->data is already set, avpkt->size is checked
* to ensure it is large enough.
* If avpkt->data is NULL, a new buffer is allocated.
+ * avpkt->size is set to the specified size.
* All other AVPacket fields will be reset with av_init_packet().
* @param size the minimum required packet size
* @return 0 on success, negative error code on failure
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 7f817cb..1380e0a 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -188,12 +188,12 @@ static int X264_frame(AVCodecContext *ctx, uint8_t *buf,
do {
bufsize = orig_bufsize;
- if (x264_encoder_encode(x4->enc, &nal, &nnal, frame? &x4->pic: NULL, &pic_out) < 0)
- return -1;
+ if (x264_encoder_encode(x4->enc, &nal, &nnal, frame? &x4->pic: NULL, &pic_out) < 0)
+ return -1;
- bufsize = encode_nals(ctx, buf, bufsize, nal, nnal, 0);
- if (bufsize < 0)
- return -1;
+ bufsize = encode_nals(ctx, buf, bufsize, nal, nnal, 0);
+ if (bufsize < 0)
+ return -1;
} while (!bufsize && !frame && x264_encoder_delayed_frames(x4->enc));
/* FIXME: libx264 now provides DTS, but AVFrame doesn't have a field for it. */
diff --git a/libavcodec/mpc.h b/libavcodec/mpc.h
index 808739f..8b4deef 100644
--- a/libavcodec/mpc.h
+++ b/libavcodec/mpc.h
@@ -66,8 +66,6 @@ typedef struct {
int buf_size;
AVLFG rnd;
int frames_to_skip;
- uint8_t *buffer;
- int buffer_size;
/* for synthesis */
DECLARE_ALIGNED(16, MPA_INT, synth_buf)[MPA_MAX_CHANNELS][512*2];
int synth_buf_offset[MPA_MAX_CHANNELS];
diff --git a/libavcodec/mpc7.c b/libavcodec/mpc7.c
index c60a621..5693c4d 100644
--- a/libavcodec/mpc7.c
+++ b/libavcodec/mpc7.c
@@ -200,34 +200,46 @@ static int mpc7_decode_frame(AVCodecContext * avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
- int buf_size = avpkt->size;
+ int buf_size;
MPCContext *c = avctx->priv_data;
GetBitContext gb;
int i, ch;
int mb = -1;
Band *bands = c->bands;
- int off, ret;
+ int off, ret, last_frame, skip;
int bits_used, bits_avail;
memset(bands, 0, sizeof(*bands) * (c->maxbands + 1));
- if(buf_size <= 4){
- av_log(avctx, AV_LOG_ERROR, "Too small buffer passed (%i bytes)\n", buf_size);
- return AVERROR(EINVAL);
+
+ buf_size = avpkt->size & ~3;
+ if (buf_size <= 0) {
+ av_log(avctx, AV_LOG_ERROR, "packet size is too small (%i bytes)\n",
+ avpkt->size);
+ return AVERROR_INVALIDDATA;
+ }
+ if (buf_size != avpkt->size) {
+ av_log(avctx, AV_LOG_WARNING, "packet size is not a multiple of 4. "
+ "extra bytes at the end will be skipped.\n");
}
+ skip = buf[0];
+ last_frame = buf[1];
+ buf += 4;
+ buf_size -= 4;
+
/* get output buffer */
- c->frame.nb_samples = buf[1] ? c->lastframelen : MPC_FRAME_SIZE;
+ c->frame.nb_samples = last_frame ? c->lastframelen : MPC_FRAME_SIZE;
if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
- av_fast_padded_malloc(&c->buffer, &c->buffer_size, FFALIGN(buf_size - 1, 4));
- if (!c->buffer)
+ av_fast_padded_malloc(&c->bits, &c->buf_size, buf_size);
+ if (!c->bits)
return AVERROR(ENOMEM);
- c->dsp.bswap_buf((uint32_t*)c->buffer, (const uint32_t*)(buf + 4), (buf_size - 4) >> 2);
- init_get_bits(&gb, c->buffer, (buf_size - 4)* 8);
- skip_bits_long(&gb, buf[0]);
+ c->dsp.bswap_buf((uint32_t *)c->bits, (const uint32_t *)buf, buf_size >> 2);
+ init_get_bits(&gb, c->bits, buf_size * 8);
+ skip_bits_long(&gb, skip);
/* read subband indexes */
for(i = 0; i <= c->maxbands; i++){
@@ -284,21 +296,21 @@ static int mpc7_decode_frame(AVCodecContext * avctx, void *data,
ff_mpc_dequantize_and_synth(c, mb, c->frame.data[0], 2);
bits_used = get_bits_count(&gb);
- bits_avail = (buf_size - 4) * 8;
- if(!buf[1] && ((bits_avail < bits_used) || (bits_used + 32 <= bits_avail))){
+ bits_avail = buf_size * 8;
+ if (!last_frame && ((bits_avail < bits_used) || (bits_used + 32 <= bits_avail))) {
av_log(NULL,0, "Error decoding frame: used %i of %i bits\n", bits_used, bits_avail);
return -1;
}
if(c->frames_to_skip){
c->frames_to_skip--;
*got_frame_ptr = 0;
- return buf_size;
+ return avpkt->size;
}
*got_frame_ptr = 1;
*(AVFrame *)data = c->frame;
- return buf_size;
+ return avpkt->size;
}
static void mpc7_decode_flush(AVCodecContext *avctx)
@@ -312,8 +324,8 @@ static void mpc7_decode_flush(AVCodecContext *avctx)
static av_cold int mpc7_decode_close(AVCodecContext *avctx)
{
MPCContext *c = avctx->priv_data;
- av_freep(&c->buffer);
- c->buffer_size = 0;
+ av_freep(&c->bits);
+ c->buf_size = 0;
return 0;
}
diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c
index d8b926d..1916c2f 100644
--- a/libavcodec/pcm.c
+++ b/libavcodec/pcm.c
@@ -194,7 +194,6 @@ static int pcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
return -1;
}
- avpkt->size = frame->nb_samples * avctx->channels * sample_size;
*got_packet_ptr = 1;
return 0;
}
diff --git a/libavcodec/ra144enc.c b/libavcodec/ra144enc.c
index 725abc2..91bf7e1 100644
--- a/libavcodec/ra144enc.c
+++ b/libavcodec/ra144enc.c
@@ -521,5 +521,5 @@ AVCodec ff_ra_144_encoder = {
.close = ra144_encode_close,
.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16,
AV_SAMPLE_FMT_NONE },
- .long_name = NULL_IF_CONFIG_SMALL("RealAudio 1.0 (14.4K) encoder"),
+ .long_name = NULL_IF_CONFIG_SMALL("RealAudio 1.0 (14.4K)"),
};
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index f21e36f..7420672 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -919,16 +919,14 @@ int ff_alloc_packet(AVPacket *avpkt, int size)
if (avpkt->data) {
uint8_t *pkt_data;
- int pkt_size;
if (avpkt->size < size)
return AVERROR(EINVAL);
pkt_data = avpkt->data;
- pkt_size = avpkt->size;
av_init_packet(avpkt);
avpkt->data = pkt_data;
- avpkt->size = pkt_size;
+ avpkt->size = size;
return 0;
} else {
return av_new_packet(avpkt, size);
diff --git a/libavcodec/vorbis.c b/libavcodec/vorbis.c
index 28176f3..fac8d0b 100644
--- a/libavcodec/vorbis.c
+++ b/libavcodec/vorbis.c
@@ -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, uint8_t y, int x1,
+static inline void render_line_unrolled(intptr_t x, int y, int x1,
intptr_t sy, int ady, int adx,
float *buf)
{
@@ -168,30 +168,30 @@ static inline void render_line_unrolled(intptr_t x, uint8_t y, int x1,
if (err >= 0) {
err += ady - adx;
y += sy;
- buf[x++] = ff_vorbis_floor1_inverse_db_table[y];
+ buf[x++] = ff_vorbis_floor1_inverse_db_table[av_clip_uint8(y)];
}
- buf[x] = ff_vorbis_floor1_inverse_db_table[y];
+ buf[x] = ff_vorbis_floor1_inverse_db_table[av_clip_uint8(y)];
}
if (x <= 0) {
if (err + ady >= 0)
y += sy;
- buf[x] = ff_vorbis_floor1_inverse_db_table[y];
+ buf[x] = ff_vorbis_floor1_inverse_db_table[av_clip_uint8(y)];
}
}
-static void render_line(int x0, uint8_t y0, int x1, int y1, float *buf)
+static void render_line(int x0, int y0, int x1, int y1, float *buf)
{
int dy = y1 - y0;
int adx = x1 - x0;
int ady = FFABS(dy);
int sy = dy < 0 ? -1 : 1;
- buf[x0] = ff_vorbis_floor1_inverse_db_table[y0];
+ buf[x0] = ff_vorbis_floor1_inverse_db_table[av_clip_uint8(y0)];
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;
- uint8_t y = y0;
+ int y = y0;
int err = -adx;
ady -= FFABS(base) * adx;
while (++x < x1) {
@@ -201,7 +201,7 @@ static void render_line(int x0, uint8_t y0, int x1, int y1, float *buf)
err -= adx;
y += sy;
}
- buf[x] = ff_vorbis_floor1_inverse_db_table[y];
+ buf[x] = ff_vorbis_floor1_inverse_db_table[av_clip_uint8(y)];
}
}
}
@@ -210,8 +210,7 @@ void ff_vorbis_floor1_render_list(vorbis_floor1_entry * list, int values,
uint16_t *y_list, int *flag,
int multiplier, float *out, int samples)
{
- int lx, i;
- uint8_t ly;
+ int lx, ly, i;
lx = 0;
ly = y_list[0] * multiplier;
for (i = 1; i < values; i++) {
diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c
index f1d9a79..f71d606 100644
--- a/libavcodec/vorbisdec.c
+++ b/libavcodec/vorbisdec.c
@@ -1256,20 +1256,20 @@ static int vorbis_floor1_decode(vorbis_context *vc,
floor1_flag[i] = 1;
if (val >= room) {
if (highroom > lowroom) {
- floor1_Y_final[i] = val - lowroom + predicted;
+ floor1_Y_final[i] = av_clip_uint16(val - lowroom + predicted);
} else {
- floor1_Y_final[i] = predicted - val + highroom - 1;
+ floor1_Y_final[i] = av_clip_uint16(predicted - val + highroom - 1);
}
} else {
if (val & 1) {
- floor1_Y_final[i] = predicted - (val + 1) / 2;
+ floor1_Y_final[i] = av_clip_uint16(predicted - (val + 1) / 2);
} else {
- floor1_Y_final[i] = predicted + val / 2;
+ floor1_Y_final[i] = av_clip_uint16(predicted + val / 2);
}
}
} else {
floor1_flag[i] = 0;
- floor1_Y_final[i] = predicted;
+ floor1_Y_final[i] = av_clip_uint16(predicted);
}
av_dlog(NULL, " Decoded floor(%d) = %u / val %u\n",
diff --git a/libavcodec/x86/Makefile b/libavcodec/x86/Makefile
index 3b8ee56..dc8c66a 100644
--- a/libavcodec/x86/Makefile
+++ b/libavcodec/x86/Makefile
@@ -83,3 +83,4 @@ OBJS-$(HAVE_MMX) += x86/dsputil_mmx.o \
x86/mpegvideo_mmx.o \
x86/simple_idct_mmx.o \
+OBJS-$(CONFIG_XMM_CLOBBER_TEST) += x86/w64xmmtest.o
diff --git a/libavcodec/x86/dsputil_yasm.asm b/libavcodec/x86/dsputil_yasm.asm
index ad9ec2c..966344f 100644
--- a/libavcodec/x86/dsputil_yasm.asm
+++ b/libavcodec/x86/dsputil_yasm.asm
@@ -1063,7 +1063,7 @@ emu_edge mmx
; %4 = CLIPD function takes min/max as float instead of int (CLIPD_SSE2)
; %5 = suffix
%macro VECTOR_CLIP_INT32 4-5
-cglobal vector_clip_int32%5, 5,5,%2, dst, src, min, max, len
+cglobal vector_clip_int32%5, 5,5,%1, dst, src, min, max, len
%if %4
cvtsi2ss m4, minm
cvtsi2ss m5, maxm
diff --git a/libavcodec/x86/w64xmmtest.c b/libavcodec/x86/w64xmmtest.c
new file mode 100644
index 0000000..f6e3de9
--- /dev/null
+++ b/libavcodec/x86/w64xmmtest.c
@@ -0,0 +1,80 @@
+/*
+ * check XMM registers for clobbers on Win64
+ * Copyright (c) 2012 Ronald S. Bultje <rsbultje@gmail.com>
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavcodec/avcodec.h"
+#include "libavutil/x86/w64xmmtest.h"
+
+wrap(avcodec_open2(AVCodecContext *avctx,
+ AVCodec *codec,
+ AVDictionary **options))
+{
+ testxmmclobbers(avcodec_open2, avctx, codec, options);
+}
+
+wrap(avcodec_decode_audio4(AVCodecContext *avctx,
+ AVFrame *frame,
+ int *got_frame_ptr,
+ AVPacket *avpkt))
+{
+ testxmmclobbers(avcodec_decode_audio4, avctx, frame,
+ got_frame_ptr, avpkt);
+}
+
+wrap(avcodec_decode_video2(AVCodecContext *avctx,
+ AVFrame *picture,
+ int *got_picture_ptr,
+ AVPacket *avpkt))
+{
+ testxmmclobbers(avcodec_decode_video2, avctx, picture,
+ got_picture_ptr, avpkt);
+}
+
+wrap(avcodec_decode_subtitle2(AVCodecContext *avctx,
+ AVSubtitle *sub,
+ int *got_sub_ptr,
+ AVPacket *avpkt))
+{
+ testxmmclobbers(avcodec_decode_subtitle2, avctx, sub,
+ got_sub_ptr, avpkt);
+}
+
+wrap(avcodec_encode_audio2(AVCodecContext *avctx,
+ AVPacket *avpkt,
+ const AVFrame *frame,
+ int *got_packet_ptr))
+{
+ testxmmclobbers(avcodec_encode_audio2, avctx, avpkt, frame,
+ got_packet_ptr);
+}
+
+wrap(avcodec_encode_video(AVCodecContext *avctx,
+ uint8_t *buf, int buf_size,
+ const AVFrame *pict))
+{
+ testxmmclobbers(avcodec_encode_video, avctx, buf, buf_size, pict);
+}
+
+wrap(avcodec_encode_subtitle(AVCodecContext *avctx,
+ uint8_t *buf, int buf_size,
+ const AVSubtitle *sub))
+{
+ testxmmclobbers(avcodec_encode_subtitle, avctx, buf, buf_size, sub);
+}
OpenPOWER on IntegriCloud