diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-02-03 02:41:47 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-02-03 03:51:32 +0100 |
commit | d77294c5e404c8a214da0e74f7836390b48b2dba (patch) | |
tree | 9c894cf54b1e18f285cc04eaf7e021e9976f4f2b /libavcodec | |
parent | 9477fa094b89645b3a34ef3bc52c4f18719ab4b3 (diff) | |
parent | e15e2a6d2a886aa9944ac9798687104c829d1541 (diff) | |
download | ffmpeg-d77294c5e404c8a214da0e74f7836390b48b2dba.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master:
libx264: fix indentation.
vorbis: fix overflows in floor1[] vector and inverse db table index.
win64: add a XMM clobber test configure option.
movdec: Parse the dvc1 atom
ARM: ac3: fix ac3_bit_alloc_calc_bap_armv6
swscale: K&R formatting cosmetics for Blackfin code
frwu: lowercase the FRWU codec name
movdec: fix dts generation in fragmented files
fate: make acodec-ac3_fixed test output raw AC3
APIchanges: add missing commit hashes
swscale: implement MMX, SSE2 and AVX functions for RGB32 input.
ra144enc: drop pointless "encoder" from .long_name
bethsoftvideo: fix palette reading.
mpc7: use av_fast_padded_malloc()
mpc7: simplify handling of packet sizes that are not a multiple of 4 bytes
doc: decoding Forward Uncompressed is supported
Fix a typo in the x86 asm version of ff_vector_clip_int32()
pcmenc: Do not set avpkt->size.
ff_alloc_packet: modify the size of the packet to match the requested size
Conflicts:
doc/APIchanges
libavcodec/libx264.c
libavcodec/mpc7.c
libavformat/isom.h
libswscale/Makefile
libswscale/bfin/yuv2rgb_bfin.c
tests/ref/fate/bethsoft-vid
tests/ref/seek/ac3_ac3
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/arm/ac3dsp_armv6.S | 15 | ||||
-rw-r--r-- | libavcodec/bethsoftvideo.c | 10 | ||||
-rw-r--r-- | libavcodec/internal.h | 1 | ||||
-rw-r--r-- | libavcodec/libx264.c | 10 | ||||
-rw-r--r-- | libavcodec/mpc.h | 2 | ||||
-rw-r--r-- | libavcodec/mpc7.c | 46 | ||||
-rw-r--r-- | libavcodec/pcm.c | 1 | ||||
-rw-r--r-- | libavcodec/ra144enc.c | 2 | ||||
-rw-r--r-- | libavcodec/utils.c | 4 | ||||
-rw-r--r-- | libavcodec/vorbis.c | 19 | ||||
-rw-r--r-- | libavcodec/vorbisdec.c | 10 | ||||
-rw-r--r-- | libavcodec/x86/Makefile | 1 | ||||
-rw-r--r-- | libavcodec/x86/dsputil_yasm.asm | 2 | ||||
-rw-r--r-- | libavcodec/x86/w64xmmtest.c | 80 |
14 files changed, 148 insertions, 55 deletions
diff --git a/libavcodec/arm/ac3dsp_armv6.S b/libavcodec/arm/ac3dsp_armv6.S index b6aee867b3..df8bfbaa03 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 d80ac166a5..d85783b109 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 72a89441c2..b7d4a6e139 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 7f817cbb4c..1380e0a438 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 808739fcc9..8b4deef689 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 c60a621c65..5693c4ddb2 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 d8b926d33e..1916c2f938 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 725abc2f38..91bf7e174f 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 f21e36fd9c..74206720ca 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 28176f3b12..fac8d0b2cd 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 f1d9a79297..f71d606dad 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 3b8ee56a49..dc8c66afde 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 ad9ec2c339..966344f7c7 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 0000000000..f6e3de9496 --- /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); +} |