diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-02-04 02:14:54 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-02-04 02:34:14 +0100 |
commit | 3b46daa31f566f9c6ef1518c1767b12e0ab2f62a (patch) | |
tree | e0baf74dc919859429488d4ea73cfc92e96db414 /libavcodec/apedec.c | |
parent | 670229ef4392fa88d6add97c0eef412a5d6083c0 (diff) | |
parent | 6f1a5e8d6b7e085171a49b8ce6a371a7c9643764 (diff) | |
download | ffmpeg-streaming-3b46daa31f566f9c6ef1518c1767b12e0ab2f62a.zip ffmpeg-streaming-3b46daa31f566f9c6ef1518c1767b12e0ab2f62a.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master:
dsputil: remove debug message in dsputil_init().
movdec: Avoid av_malloc(0) in stss
build: Drop YASM-OBJS-FFT from SUBDIR_VARS.
build: Drop unused X86-OBJS variable.
avconv: remove debugging cruft from do_video_out().
avconv: factorize setting stream_index for the output packet.
frame{crc/md5}: set the stream timebase from codec timebase.
apedec: remove unneeded #include of get_bits.h and associated macro
apedec: av_fast_malloc() instead of av_realloc()
apedec: fix handling of packet sizes that are not a multiple of 4 bytes
Conflicts:
libavcodec/apedec.c
tests/ref/fate/4xm-1
tests/ref/fate/4xm-2
tests/ref/fate/aasc
tests/ref/fate/armovie-escape124
tests/ref/fate/bethsoft-vid
tests/ref/fate/cljr
tests/ref/fate/creatureshock-avs
tests/ref/fate/cscd
tests/ref/fate/cvid-partial
tests/ref/fate/deluxepaint-anm
tests/ref/fate/dfa1
tests/ref/fate/dfa10
tests/ref/fate/dfa11
tests/ref/fate/dfa2
tests/ref/fate/dfa3
tests/ref/fate/dfa4
tests/ref/fate/dfa5
tests/ref/fate/dfa6
tests/ref/fate/dfa7
tests/ref/fate/dfa8
tests/ref/fate/dfa9
tests/ref/fate/film-cvid-pcm-stereo-8bit
tests/ref/fate/flic-af11-palette-change
tests/ref/fate/flic-magiccarpet
tests/ref/fate/fraps-v2
tests/ref/fate/fraps-v3
tests/ref/fate/h264-lossless
tests/ref/fate/interplay-mve-16bit
tests/ref/fate/interplay-mve-8bit
tests/ref/fate/mimic
tests/ref/fate/motionpixels
tests/ref/fate/mpeg2-field-enc
tests/ref/fate/msvideo1-16bit
tests/ref/fate/mtv
tests/ref/fate/nuv
tests/ref/fate/pictor
tests/ref/fate/prores-alpha
tests/ref/fate/ptx
tests/ref/fate/qtrle-16bit
tests/ref/fate/qtrle-1bit
tests/ref/fate/quickdraw
tests/ref/fate/rpza
tests/ref/fate/sierra-vmd
tests/ref/fate/targa-conformance-CCM8
tests/ref/fate/targa-conformance-UCM8
tests/ref/fate/tiertex-seq
tests/ref/fate/truemotion1-15
tests/ref/fate/truemotion1-24
tests/ref/fate/tscc-15bit
tests/ref/fate/tscc-32bit
tests/ref/fate/v210
tests/ref/fate/vc1-ism
tests/ref/fate/vc1_sa00040
tests/ref/fate/vc1_sa00050
tests/ref/fate/vc1_sa10091
tests/ref/fate/vc1_sa20021
tests/ref/fate/vmnc-16bit
tests/ref/fate/vmnc-32bit
tests/ref/fate/vp5
tests/ref/fate/vp8-sign-bias
tests/ref/fate/vqa-cc
tests/ref/fate/wmv8-drm
tests/ref/fate/yop
tests/ref/fate/zmbv-8bit
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/apedec.c')
-rw-r--r-- | libavcodec/apedec.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c index 58ffd90..7766e15 100644 --- a/libavcodec/apedec.c +++ b/libavcodec/apedec.c @@ -20,10 +20,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#define BITSTREAM_READER_LE #include "avcodec.h" #include "dsputil.h" -#include "get_bits.h" #include "bytestream.h" #include "libavutil/audioconvert.h" #include "libavutil/avassert.h" @@ -155,6 +153,7 @@ typedef struct APEContext { uint8_t *data; ///< current frame data uint8_t *data_end; ///< frame data end + int data_size; ///< frame data allocated size const uint8_t *ptr; ///< current position in frame data int error; @@ -171,6 +170,8 @@ static av_cold int ape_decode_close(AVCodecContext *avctx) av_freep(&s->filterbuf[i]); av_freep(&s->data); + s->data_size = 0; + return 0; } @@ -814,7 +815,6 @@ static int ape_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; - int buf_size = avpkt->size; APEContext *s = avctx->priv_data; int16_t *samples; int i, ret; @@ -827,18 +827,23 @@ static int ape_decode_frame(AVCodecContext *avctx, void *data, if(!s->samples){ uint32_t nblocks, offset; + int buf_size; - if (!buf_size) { + if (!avpkt->size) { *got_frame_ptr = 0; return 0; } - if (buf_size < 8) { + if (avpkt->size < 8) { av_log(avctx, AV_LOG_ERROR, "Packet is too small\n"); return AVERROR_INVALIDDATA; } + buf_size = avpkt->size & ~3; + 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"); + } - av_free(s->data); - s->data = av_malloc(FFALIGN(buf_size, 4)); + av_fast_malloc(&s->data, &s->data_size, buf_size); if (!s->data) return AVERROR(ENOMEM); s->dsp.bswap_buf((uint32_t*)s->data, (const uint32_t*)buf, buf_size >> 2); @@ -873,12 +878,12 @@ static int ape_decode_frame(AVCodecContext *avctx, void *data, return AVERROR_INVALIDDATA; } - bytes_used = buf_size; + bytes_used = avpkt->size; } if (!s->data) { *got_frame_ptr = 0; - return buf_size; + return avpkt->size; } blockstodecode = FFMIN(BLOCKS_PER_LOOP, s->samples); |