diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-01-05 02:03:12 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-01-05 02:03:12 +0100 |
commit | 7f83db312454b3673a4dfd34745428f61309ab30 (patch) | |
tree | 27c92b052b83e4b3bf95a33fbe6979aaa00f8184 /libavcodec | |
parent | c4eec85a1fa768025f88261995af08f1dba9685d (diff) | |
parent | feb15cee5e19a1e31d075ec08d598d64c2dc38ef (diff) | |
download | ffmpeg-7f83db312454b3673a4dfd34745428f61309ab30.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master: (46 commits)
mtv: Make sure audio_subsegments is not 0
v4l2: use V4L2_FMT_FLAG_EMULATED only if it is defined
avconv: add symbolic names for -vsync parameters
flvdec: Fix compiler warning for uninitialized variables
rtsp: Fix compiler warning for uninitialized variable
ulti: convert to new bytestream API.
swscale: Use standard multiple inclusion guards in ppc/ header files.
Place some START_TIMER invocations in separate blocks.
v4l2: list available formats
v4l2: set the proper codec_tag
v4l2: refactor device_open
v4l2: simplify away io_method
v4l2: cosmetics
v4l2: uniform and format options
v4l2: do not force interlaced mode
avio: exit early in fill_buffer without read_packet
vc1dec: fix invalid memory access for small video dimensions
rv34: fix invalid memory access for small video dimensions
rv34: joint coefficient decoding and dequantization
avplay: Don't call avio_set_interrupt_cb(NULL)
...
Conflicts:
Changelog
avconv.c
doc/APIchanges
doc/indevs.texi
libavcodec/adxenc.c
libavcodec/dnxhdenc.c
libavcodec/h264.c
libavdevice/v4l2.c
libavformat/flvdec.c
libavformat/mtv.c
libswscale/utils.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/adxdec.c | 8 | ||||
-rw-r--r-- | libavcodec/adxenc.c | 185 | ||||
-rw-r--r-- | libavcodec/arm/rv34dsp_init_neon.c | 3 | ||||
-rw-r--r-- | libavcodec/arm/rv34dsp_neon.S | 24 | ||||
-rw-r--r-- | libavcodec/bytestream.h | 6 | ||||
-rw-r--r-- | libavcodec/cabac.c | 31 | ||||
-rw-r--r-- | libavcodec/cabac.h | 61 | ||||
-rw-r--r-- | libavcodec/dnxhdenc.c | 5 | ||||
-rw-r--r-- | libavcodec/h264.c | 13 | ||||
-rw-r--r-- | libavcodec/indeo5.c | 4 | ||||
-rw-r--r-- | libavcodec/libspeexenc.c | 12 | ||||
-rw-r--r-- | libavcodec/rv34.c | 85 | ||||
-rw-r--r-- | libavcodec/rv34data.h | 10 | ||||
-rw-r--r-- | libavcodec/rv34dsp.c | 16 | ||||
-rw-r--r-- | libavcodec/rv34dsp.h | 1 | ||||
-rw-r--r-- | libavcodec/ulti.c | 72 | ||||
-rw-r--r-- | libavcodec/vc1dec.c | 6 |
17 files changed, 190 insertions, 352 deletions
diff --git a/libavcodec/adxdec.c b/libavcodec/adxdec.c index fdff6875e1..ec4b1041af 100644 --- a/libavcodec/adxdec.c +++ b/libavcodec/adxdec.c @@ -165,6 +165,13 @@ static int adx_decode_frame(AVCodecContext *avctx, void *data, return buf - avpkt->data; } +static void adx_decode_flush(AVCodecContext *avctx) +{ + ADXContext *c = avctx->priv_data; + memset(c->prev, 0, sizeof(c->prev)); + c->eof = 0; +} + AVCodec ff_adpcm_adx_decoder = { .name = "adpcm_adx", .type = AVMEDIA_TYPE_AUDIO, @@ -172,6 +179,7 @@ AVCodec ff_adpcm_adx_decoder = { .priv_data_size = sizeof(ADXContext), .init = adx_decode_init, .decode = adx_decode_frame, + .flush = adx_decode_flush, .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("SEGA CRI ADX ADPCM"), }; diff --git a/libavcodec/adxenc.c b/libavcodec/adxenc.c index 51545fa06c..b029e2eb78 100644 --- a/libavcodec/adxenc.c +++ b/libavcodec/adxenc.c @@ -19,9 +19,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libavutil/intreadwrite.h" #include "avcodec.h" #include "adx.h" +#include "bytestream.h" #include "put_bits.h" /** @@ -33,167 +33,135 @@ * adx2wav & wav2adx http://www.geocities.co.jp/Playtown/2004/ */ -/* 18 bytes <-> 32 samples */ - -static void adx_encode(ADXContext *c, unsigned char *adx, const short *wav, - ADXChannelState *prev) +static void adx_encode(ADXContext *c, uint8_t *adx, const int16_t *wav, + ADXChannelState *prev, int channels) { PutBitContext pb; int scale; - int i; - int s0,s1,s2,d; - int max=0; - int min=0; - int data[32]; + int i, j; + int s0, s1, s2, d; + int max = 0; + int min = 0; + int data[BLOCK_SAMPLES]; s1 = prev->s1; s2 = prev->s2; - for(i=0;i<32;i++) { + for (i = 0, j = 0; j < 32; i += channels, j++) { s0 = wav[i]; d = ((s0 << COEFF_BITS) - c->coeff[0] * s1 - c->coeff[1] * s2) >> COEFF_BITS; - data[i]=d; - if (max<d) max=d; - if (min>d) min=d; + data[j] = d; + if (max < d) + max = d; + if (min > d) + min = d; s2 = s1; s1 = s0; } prev->s1 = s1; prev->s2 = s2; - /* -8..+7 */ - - if (max==0 && min==0) { - memset(adx,0,18); + if (max == 0 && min == 0) { + memset(adx, 0, BLOCK_SIZE); return; } - if (max/7>-min/8) scale = max/7; - else scale = -min/8; + if (max / 7 > -min / 8) + scale = max / 7; + else + scale = -min / 8; - if (scale==0) scale=1; + if (scale == 0) + scale = 1; AV_WB16(adx, scale); init_put_bits(&pb, adx + 2, 16); - for (i = 0; i < 32; i++) - put_sbits(&pb, 4, av_clip(data[i]/scale, -8, 7)); + for (i = 0; i < BLOCK_SAMPLES; i++) + put_sbits(&pb, 4, av_clip(data[i] / scale, -8, 7)); flush_put_bits(&pb); } -static int adx_encode_header(AVCodecContext *avctx,unsigned char *buf,size_t bufsize) +#define HEADER_SIZE 36 + +static int adx_encode_header(AVCodecContext *avctx, uint8_t *buf, int bufsize) { -#if 0 - struct { - uint32_t offset; /* 0x80000000 + sample start - 4 */ - unsigned char unknown1[3]; /* 03 12 04 */ - unsigned char channel; /* 1 or 2 */ - uint32_t freq; - uint32_t size; - uint32_t unknown2; /* 01 f4 03 00 */ - uint32_t unknown3; /* 00 00 00 00 */ - uint32_t unknown4; /* 00 00 00 00 */ - - /* if loop - unknown3 00 15 00 01 - unknown4 00 00 00 01 - long loop_start_sample; - long loop_start_byte; - long loop_end_sample; - long loop_end_byte; - long - */ - } adxhdr; /* big endian */ - /* offset-6 "(c)CRI" */ -#endif ADXContext *c = avctx->priv_data; - AV_WB32(buf+0x00,0x80000000|0x20); - AV_WB32(buf+0x04,0x03120400|avctx->channels); - AV_WB32(buf+0x08,avctx->sample_rate); - AV_WB32(buf+0x0c,0); /* FIXME: set after */ - AV_WB16(buf + 0x10, c->cutoff); - AV_WB32(buf + 0x12, 0x03000000); - AV_WB32(buf + 0x16, 0x00000000); - AV_WB32(buf + 0x1a, 0x00000000); - memcpy (buf + 0x1e, "(c)CRI", 6); - return 0x20+4; + if (bufsize < HEADER_SIZE) + return AVERROR(EINVAL); + + bytestream_put_be16(&buf, 0x8000); /* header signature */ + bytestream_put_be16(&buf, HEADER_SIZE - 4); /* copyright offset */ + bytestream_put_byte(&buf, 3); /* encoding */ + bytestream_put_byte(&buf, BLOCK_SIZE); /* block size */ + bytestream_put_byte(&buf, 4); /* sample size */ + bytestream_put_byte(&buf, avctx->channels); /* channels */ + bytestream_put_be32(&buf, avctx->sample_rate); /* sample rate */ + bytestream_put_be32(&buf, 0); /* total sample count */ + bytestream_put_be16(&buf, c->cutoff); /* cutoff frequency */ + bytestream_put_byte(&buf, 3); /* version */ + bytestream_put_byte(&buf, 0); /* flags */ + bytestream_put_be32(&buf, 0); /* unknown */ + bytestream_put_be32(&buf, 0); /* loop enabled */ + bytestream_put_be16(&buf, 0); /* padding */ + bytestream_put_buffer(&buf, "(c)CRI", 6); /* copyright signature */ + + return HEADER_SIZE; } static av_cold int adx_encode_init(AVCodecContext *avctx) { ADXContext *c = avctx->priv_data; - if (avctx->channels > 2) - return -1; /* only stereo or mono =) */ - avctx->frame_size = 32; - - avctx->coded_frame= avcodec_alloc_frame(); - avctx->coded_frame->key_frame= 1; + if (avctx->channels > 2) { + av_log(avctx, AV_LOG_ERROR, "Invalid number of channels\n"); + return AVERROR(EINVAL); + } + avctx->frame_size = BLOCK_SAMPLES; -// avctx->bit_rate = avctx->sample_rate*avctx->channels*18*8/32; + avctx->coded_frame = avcodec_alloc_frame(); /* the cutoff can be adjusted, but this seems to work pretty well */ c->cutoff = 500; ff_adx_calculate_coeffs(c->cutoff, avctx->sample_rate, COEFF_BITS, c->coeff); - av_log(avctx, AV_LOG_DEBUG, "adx encode init\n"); - return 0; } static av_cold int adx_encode_close(AVCodecContext *avctx) { av_freep(&avctx->coded_frame); - return 0; } -static int adx_encode_frame(AVCodecContext *avctx, - uint8_t *frame, int buf_size, void *data) +static int adx_encode_frame(AVCodecContext *avctx, uint8_t *frame, + int buf_size, void *data) { - ADXContext *c = avctx->priv_data; - const short *samples = data; - unsigned char *dst = frame; - int rest = avctx->frame_size; - -/* - input data size = - ffmpeg.c: do_audio_out() - frame_bytes = enc->frame_size * 2 * enc->channels; -*/ + ADXContext *c = avctx->priv_data; + const int16_t *samples = data; + uint8_t *dst = frame; + int ch; -// printf("sz=%d ",buf_size); fflush(stdout); if (!c->header_parsed) { - int hdrsize = adx_encode_header(avctx,dst,buf_size); - dst+=hdrsize; + int hdrsize; + if ((hdrsize = adx_encode_header(avctx, dst, buf_size)) < 0) { + av_log(avctx, AV_LOG_ERROR, "output buffer is too small\n"); + return AVERROR(EINVAL); + } + dst += hdrsize; + buf_size -= hdrsize; c->header_parsed = 1; } + if (buf_size < BLOCK_SIZE * avctx->channels) { + av_log(avctx, AV_LOG_ERROR, "output buffer is too small\n"); + return AVERROR(EINVAL); + } - if (avctx->channels==1) { - while(rest>=32) { - adx_encode(c, dst, samples, c->prev); - dst+=18; - samples+=32; - rest-=32; - } - } else { - while(rest>=32*2) { - short tmpbuf[32*2]; - int i; - - for(i=0;i<32;i++) { - tmpbuf[i] = samples[i*2]; - tmpbuf[i+32] = samples[i*2+1]; - } - - adx_encode(c, dst, tmpbuf, c->prev); - adx_encode(c, dst + 18, tmpbuf + 32, c->prev + 1); - dst+=18*2; - samples+=32*2; - rest-=32*2; - } + for (ch = 0; ch < avctx->channels; ch++) { + adx_encode(c, dst, samples + ch, &c->prev[ch], avctx->channels); + dst += BLOCK_SIZE; } - return dst-frame; + return dst - frame; } AVCodec ff_adpcm_adx_encoder = { @@ -204,6 +172,7 @@ AVCodec ff_adpcm_adx_encoder = { .init = adx_encode_init, .encode = adx_encode_frame, .close = adx_encode_close, - .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, - .long_name = NULL_IF_CONFIG_SMALL("SEGA CRI ADX ADPCM"), + .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16, + AV_SAMPLE_FMT_NONE }, + .long_name = NULL_IF_CONFIG_SMALL("SEGA CRI ADX ADPCM"), }; diff --git a/libavcodec/arm/rv34dsp_init_neon.c b/libavcodec/arm/rv34dsp_init_neon.c index acf2a7dcd3..9a09fde7a9 100644 --- a/libavcodec/arm/rv34dsp_init_neon.c +++ b/libavcodec/arm/rv34dsp_init_neon.c @@ -25,12 +25,9 @@ void ff_rv34_inv_transform_neon(DCTELEM *block); void ff_rv34_inv_transform_noround_neon(DCTELEM *block); -void ff_rv34_dequant4x4_neon(DCTELEM *block, int Qdc, int Q); void ff_rv34dsp_init_neon(RV34DSPContext *c, DSPContext* dsp) { c->rv34_inv_transform_tab[0] = ff_rv34_inv_transform_neon; c->rv34_inv_transform_tab[1] = ff_rv34_inv_transform_noround_neon; - - c->rv34_dequant4x4 = ff_rv34_dequant4x4_neon; } diff --git a/libavcodec/arm/rv34dsp_neon.S b/libavcodec/arm/rv34dsp_neon.S index 423b537fb9..f700f5c321 100644 --- a/libavcodec/arm/rv34dsp_neon.S +++ b/libavcodec/arm/rv34dsp_neon.S @@ -107,27 +107,3 @@ function ff_rv34_inv_transform_noround_neon, export=1 vst4.16 {d0[3], d1[3], d2[3], d3[3]}, [r2,:64], r1 bx lr endfunc - -function ff_rv34_dequant4x4_neon, export=1 - mov r3, r0 - mov r12, #16 - vdup.16 q0, r2 - vmov.16 d0[0], r1 - vld1.16 {d2}, [r0,:64], r12 - vld1.16 {d4}, [r0,:64], r12 - vld1.16 {d6}, [r0,:64], r12 - vld1.16 {d16}, [r0,:64], r12 - vmull.s16 q1, d2, d0 - vmull.s16 q2, d4, d1 - vmull.s16 q3, d6, d1 - vmull.s16 q8, d16, d1 - vqrshrn.s32 d2, q1, #4 - vqrshrn.s32 d4, q2, #4 - vqrshrn.s32 d6, q3, #4 - vqrshrn.s32 d16, q8, #4 - vst1.16 {d2}, [r3,:64], r12 - vst1.16 {d4}, [r3,:64], r12 - vst1.16 {d6}, [r3,:64], r12 - vst1.16 {d16}, [r3,:64], r12 - bx lr -endfunc diff --git a/libavcodec/bytestream.h b/libavcodec/bytestream.h index 7ca36f8ad3..73ea0c880f 100644 --- a/libavcodec/bytestream.h +++ b/libavcodec/bytestream.h @@ -39,11 +39,15 @@ static av_always_inline void bytestream_put_ ##name(uint8_t **b, const type valu write(*b, value);\ (*b) += bytes;\ }\ +static av_always_inline type bytestream2_get_ ## name ## u(GetByteContext *g)\ +{\ + return bytestream_get_ ## name(&g->buffer);\ +}\ static av_always_inline type bytestream2_get_ ## name(GetByteContext *g)\ {\ if (g->buffer_end - g->buffer < bytes)\ return 0;\ - return bytestream_get_ ## name(&g->buffer);\ + return bytestream2_get_ ## name ## u(g);\ }\ static av_always_inline type bytestream2_peek_ ## name(GetByteContext *g)\ {\ diff --git a/libavcodec/cabac.c b/libavcodec/cabac.c index e03043f91f..c603dafddd 100644 --- a/libavcodec/cabac.c +++ b/libavcodec/cabac.c @@ -109,10 +109,6 @@ void ff_init_cabac_encoder(CABACContext *c, uint8_t *buf, int buf_size){ c->low= 0; c->range= 0x1FE; c->outstanding_count= 0; -#ifdef STRICT_LIMITS - c->sym_count =0; -#endif - c->pb.bit_left++; //avoids firstBitFlag } @@ -183,10 +179,6 @@ static void put_cabac(CABACContext *c, uint8_t * const state, int bit){ } renorm_cabac_encoder(c); - -#ifdef STRICT_LIMITS - c->symCount++; -#endif } /** @@ -208,10 +200,6 @@ static void put_cabac_bypass(CABACContext *c, int bit){ put_cabac_bit(c, 1); c->low -= 0x400; } - -#ifdef STRICT_LIMITS - c->symCount++; -#endif } /** @@ -236,10 +224,6 @@ static int put_cabac_terminate(CABACContext *c, int bit){ flush_put_bits(&c->pb); //FIXME FIXME FIXME XXX wrong } -#ifdef STRICT_LIMITS - c->symCount++; -#endif - return (put_bits_count(&c->pb)+7)>>3; } @@ -365,21 +349,6 @@ START_TIMER av_log(NULL, AV_LOG_ERROR, "CABAC failure at %d\n", i); STOP_TIMER("get_cabac") } -#if 0 - for(i=0; i<SIZE; i++){ -START_TIMER - if( r[i] != get_cabac_u(&c, state, (i&1) ? 6 : 7, 3, i&1) ) - av_log(NULL, AV_LOG_ERROR, "CABAC unary (truncated) binarization failure at %d\n", i); -STOP_TIMER("get_cabac_u") - } - - for(i=0; i<SIZE; i++){ -START_TIMER - if( r[i] != get_cabac_ueg(&c, state, 3, 0, 1, 2)) - av_log(NULL, AV_LOG_ERROR, "CABAC unary (truncated) binarization failure at %d\n", i); -STOP_TIMER("get_cabac_ueg") - } -#endif if(!get_cabac_terminate(&c)) av_log(NULL, AV_LOG_ERROR, "where's the Terminator?\n"); diff --git a/libavcodec/cabac.h b/libavcodec/cabac.h index ed156e6fca..d31d75b030 100644 --- a/libavcodec/cabac.h +++ b/libavcodec/cabac.h @@ -41,9 +41,6 @@ typedef struct CABACContext{ int low; int range; int outstanding_count; -#ifdef STRICT_LIMITS - int symCount; -#endif const uint8_t *bytestream_start; const uint8_t *bytestream; const uint8_t *bytestream_end; @@ -216,62 +213,4 @@ static int av_unused get_cabac_terminate(CABACContext *c){ } } -#if 0 -/** - * Get (truncated) unary binarization. - */ -static int get_cabac_u(CABACContext *c, uint8_t * state, int max, int max_index, int truncated){ - int i; - - for(i=0; i<max; i++){ - if(get_cabac(c, state)==0) - return i; - - if(i< max_index) state++; - } - - return truncated ? max : -1; -} - -/** - * get unary exp golomb k-th order binarization. - */ -static int get_cabac_ueg(CABACContext *c, uint8_t * state, int max, int is_signed, int k, int max_index){ - int i, v; - int m= 1<<k; - - if(get_cabac(c, state)==0) - return 0; - - if(0 < max_index) state++; - - for(i=1; i<max; i++){ - if(get_cabac(c, state)==0){ - if(is_signed && get_cabac_bypass(c)){ - return -i; - }else - return i; - } - - if(i < max_index) state++; - } - - while(get_cabac_bypass(c)){ - i+= m; - m+= m; - } - - v=0; - while(m>>=1){ - v+= v + get_cabac_bypass(c); - } - i += v; - - if(is_signed && get_cabac_bypass(c)){ - return -i; - }else - return i; -} -#endif /* 0 */ - #endif /* AVCODEC_CABAC_H */ diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c index 7021a70650..e4c6274ae4 100644 --- a/libavcodec/dnxhdenc.c +++ b/libavcodec/dnxhdenc.c @@ -578,9 +578,8 @@ static int dnxhd_encode_thread(AVCodecContext *avctx, void *arg, int jobnr, int for (i = 0; i < 8; i++) { DCTELEM *block = ctx->blocks[i]; - int last_index, overflow; - int n = dnxhd_switch_matrix(ctx, i); - last_index = ctx->m.dct_quantize(&ctx->m, block, 4&(2*i), qscale, &overflow); + int overflow, n = dnxhd_switch_matrix(ctx, i); + int last_index = ctx->m.dct_quantize(&ctx->m, block, 4&(2*i), qscale, &overflow); //START_TIMER; dnxhd_encode_block(ctx, block, last_index, n); //STOP_TIMER("encode_block"); diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 8a79311f7c..8cd9fe72ef 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -4051,7 +4051,7 @@ static int decode_frame(AVCodecContext *avctx, H264Context *h = avctx->priv_data; MpegEncContext *s = &h->s; AVFrame *pict = data; - int buf_index; + int buf_index = 0; Picture *out; int i, out_idx; @@ -4081,7 +4081,7 @@ static int decode_frame(AVCodecContext *avctx, *pict= *(AVFrame*)out; } - return buf_size; + return buf_index; } if(h->is_avc && buf_size >= 9 && buf[0]==1 && buf[2]==0 && (buf[4]&0xFC)==0xFC && (buf[5]&0x1F) && buf[8]==0x67){ int cnt= buf[5]&0x1f; @@ -4112,7 +4112,6 @@ not_extra: if (!s->current_picture_ptr && h->nal_unit_type == NAL_END_SEQUENCE) { av_assert0(buf_index <= buf_size); - buf_size = buf_index; goto out; } @@ -4193,9 +4192,7 @@ int main(void){ init_get_bits(&gb, temp, 8*SIZE); for(i=0; i<COUNT; i++){ - int j, s; - - s= show_bits(&gb, 24); + int j, s = show_bits(&gb, 24); {START_TIMER j= get_ue_golomb(&gb); @@ -4218,9 +4215,7 @@ int main(void){ init_get_bits(&gb, temp, 8*SIZE); for(i=0; i<COUNT; i++){ - int j, s; - - s= show_bits(&gb, 24); + int j, s = show_bits(&gb, 24); {START_TIMER j= get_se_golomb(&gb); diff --git a/libavcodec/indeo5.c b/libavcodec/indeo5.c index fc534dd4e4..b1c50c2adb 100644 --- a/libavcodec/indeo5.c +++ b/libavcodec/indeo5.c @@ -760,7 +760,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, switch_buffers(ctx); - //START_TIMER; + //{ START_TIMER; if (ctx->frame_type != FRAMETYPE_NULL) { for (p = 0; p < 3; p++) { @@ -775,7 +775,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, } } - //STOP_TIMER("decode_planes"); + //STOP_TIMER("decode_planes"); } if (ctx->frame.data[0]) avctx->release_buffer(avctx, &ctx->frame); diff --git a/libavcodec/libspeexenc.c b/libavcodec/libspeexenc.c index a3176d1388..c89f0748a1 100644 --- a/libavcodec/libspeexenc.c +++ b/libavcodec/libspeexenc.c @@ -83,7 +83,8 @@ typedef struct { int abr; ///< flag to enable ABR int pkt_frame_count; ///< frame count for the current packet int lookahead; ///< encoder delay - int sample_count; ///< total sample count (used for pts) + int64_t next_pts; ///< next pts, in sample_rate time base + int pkt_sample_count; ///< sample count in the current packet } LibSpeexEncContext; static av_cold void print_enc_params(AVCodecContext *avctx, @@ -201,7 +202,7 @@ static av_cold int encode_init(AVCodecContext *avctx) /* set encoding delay */ speex_encoder_ctl(s->enc_state, SPEEX_GET_LOOKAHEAD, &s->lookahead); - s->sample_count = -s->lookahead; + s->next_pts = -s->lookahead; /* create header packet bytes from header struct */ /* note: libspeex allocates the memory for header_data, which is freed @@ -235,7 +236,6 @@ static int encode_frame(AVCodecContext *avctx, uint8_t *frame, int buf_size, { LibSpeexEncContext *s = avctx->priv_data; int16_t *samples = data; - int sample_count = s->sample_count; if (data) { /* encode Speex frame */ @@ -243,7 +243,7 @@ static int encode_frame(AVCodecContext *avctx, uint8_t *frame, int buf_size, speex_encode_stereo_int(samples, s->header.frame_size, &s->bits); speex_encode_int(s->enc_state, samples, &s->bits); s->pkt_frame_count++; - s->sample_count += avctx->frame_size; + s->pkt_sample_count += avctx->frame_size; } else { /* handle end-of-stream */ if (!s->pkt_frame_count) @@ -259,8 +259,10 @@ static int encode_frame(AVCodecContext *avctx, uint8_t *frame, int buf_size, if (s->pkt_frame_count == s->frames_per_packet) { s->pkt_frame_count = 0; avctx->coded_frame->pts = - av_rescale_q(sample_count, (AVRational){ 1, avctx->sample_rate }, + av_rescale_q(s->next_pts, (AVRational){ 1, avctx->sample_rate }, avctx->time_base); + s->next_pts += s->pkt_sample_count; + s->pkt_sample_count = 0; if (buf_size > speex_bits_nbytes(&s->bits)) { int ret = speex_bits_write(&s->bits, frame, buf_size); speex_bits_reset(&s->bits); diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c index afe8c1f874..12a539e89a 100644 --- a/libavcodec/rv34.c +++ b/libavcodec/rv34.c @@ -212,7 +212,7 @@ static int rv34_decode_cbp(GetBitContext *gb, RV34VLC *vlc, int table) /** * Get one coefficient value from the bistream and store it. */ -static inline void decode_coeff(DCTELEM *dst, int coef, int esc, GetBitContext *gb, VLC* vlc) +static inline void decode_coeff(DCTELEM *dst, int coef, int esc, GetBitContext *gb, VLC* vlc, int q) { if(coef){ if(coef == esc){ @@ -225,14 +225,14 @@ static inline void decode_coeff(DCTELEM *dst, int coef, int esc, GetBitContext * } if(get_bits1(gb)) coef = -coef; - *dst = coef; + *dst = (coef*q + 8) >> 4; } } /** * Decode 2x2 subblock of coefficients. */ -static inline void decode_subblock(DCTELEM *dst, int code, const int is_block2, GetBitContext *gb, VLC *vlc) +static inline void decode_subblock(DCTELEM *dst, int code, const int is_block2, GetBitContext *gb, VLC *vlc, int q) { int coeffs[4]; @@ -240,15 +240,35 @@ static inline void decode_subblock(DCTELEM *dst, int code, const int is_block2, coeffs[1] = modulo_three_table[code][1]; coeffs[2] = modulo_three_table[code][2]; coeffs[3] = modulo_three_table[code][3]; - decode_coeff(dst , coeffs[0], 3, gb, vlc); + decode_coeff(dst , coeffs[0], 3, gb, vlc, q); if(is_block2){ - decode_coeff(dst+8, coeffs[1], 2, gb, vlc); - decode_coeff(dst+1, coeffs[2], 2, gb, vlc); + decode_coeff(dst+8, coeffs[1], 2, gb, vlc, q); + decode_coeff(dst+1, coeffs[2], 2, gb, vlc, q); }else{ - decode_coeff(dst+1, coeffs[1], 2, gb, vlc); - decode_coeff(dst+8, coeffs[2], 2, gb, vlc); + decode_coeff(dst+1, coeffs[1], 2, gb, vlc, q); + decode_coeff(dst+8, coeffs[2], 2, gb, vlc, q); } - decode_coeff(dst+9, coeffs[3], 2, gb, vlc); + decode_coeff(dst+9, coeffs[3], 2, gb, vlc, q); +} + +static inline void decode_subblock3(DCTELEM *dst, int code, const int is_block2, GetBitContext *gb, VLC *vlc, + int q_dc, int q_ac1, int q_ac2) +{ + int coeffs[4]; + + coeffs[0] = modulo_three_table[code][0]; + coeffs[1] = modulo_three_table[code][1]; + coeffs[2] = modulo_three_table[code][2]; + coeffs[3] = modulo_three_table[code][3]; + decode_coeff(dst , coeffs[0], 3, gb, vlc, q_dc); + if(is_block2){ + decode_coeff(dst+8, coeffs[1], 2, gb, vlc, q_ac1); + decode_coeff(dst+1, coeffs[2], 2, gb, vlc, q_ac1); + }else{ + decode_coeff(dst+1, coeffs[1], 2, gb, vlc, q_ac1); + decode_coeff(dst+8, coeffs[2], 2, gb, vlc, q_ac1); + } + decode_coeff(dst+9, coeffs[3], 2, gb, vlc, q_ac2); } /** @@ -262,7 +282,7 @@ static inline void decode_subblock(DCTELEM *dst, int code, const int is_block2, * o--o */ -static inline void rv34_decode_block(DCTELEM *dst, GetBitContext *gb, RV34VLC *rvlc, int fc, int sc) +static inline void rv34_decode_block(DCTELEM *dst, GetBitContext *gb, RV34VLC *rvlc, int fc, int sc, int q_dc, int q_ac1, int q_ac2) { int code, pattern; @@ -271,40 +291,24 @@ static inline void rv34_decode_block(DCTELEM *dst, GetBitContext *gb, RV34VLC *r pattern = code & 0x7; code >>= 3; - decode_subblock(dst, code, 0, gb, &rvlc->coefficient); + decode_subblock3(dst, code, 0, gb, &rvlc->coefficient, q_dc, q_ac1, q_ac2); if(pattern & 4){ code = get_vlc2(gb, rvlc->second_pattern[sc].table, 9, 2); - decode_subblock(dst + 2, code, 0, gb, &rvlc->coefficient); + decode_subblock(dst + 2, code, 0, gb, &rvlc->coefficient, q_ac2); } if(pattern & 2){ // Looks like coefficients 1 and 2 are swapped for this block code = get_vlc2(gb, rvlc->second_pattern[sc].table, 9, 2); - decode_subblock(dst + 8*2, code, 1, gb, &rvlc->coefficient); + decode_subblock(dst + 8*2, code, 1, gb, &rvlc->coefficient, q_ac2); } if(pattern & 1){ code = get_vlc2(gb, rvlc->third_pattern[sc].table, 9, 2); - decode_subblock(dst + 8*2+2, code, 0, gb, &rvlc->coefficient); + decode_subblock(dst + 8*2+2, code, 0, gb, &rvlc->coefficient, q_ac2); } } /** - * Dequantize 4x4 block of DC values for 16x16 macroblock. - * @todo optimize - */ -static inline void rv34_dequant4x4_16x16(DCTELEM *block, int Qdc, int Q) -{ - int i; - - for(i = 0; i < 3; i++) - block[rv34_dezigzag[i]] = (block[rv34_dezigzag[i]] * Qdc + 8) >> 4; - for(; i < 16; i++) - block[rv34_dezigzag[i]] = (block[rv34_dezigzag[i]] * Q + 8) >> 4; -} -/** @} */ //block functions - - -/** * @name RV30/40 bitstream parsing * @{ */ @@ -676,8 +680,9 @@ static inline void rv34_mc(RV34DecContext *r, const int block_type, srcY += src_y * s->linesize + src_x; srcU += uvsrc_y * s->uvlinesize + uvsrc_x; srcV += uvsrc_y * s->uvlinesize + uvsrc_x; - if( (unsigned)(src_x - !!lx*2) > s->h_edge_pos - !!lx*2 - (width <<3) - 4 - || (unsigned)(src_y - !!ly*2) > s->v_edge_pos - !!ly*2 - (height<<3) - 4){ + if(s->h_edge_pos - (width << 3) < 6 || s->v_edge_pos - (height << 3) < 6 || + (unsigned)(src_x - !!lx*2) > s->h_edge_pos - !!lx*2 - (width <<3) - 4 || + (unsigned)(src_y - !!ly*2) > s->v_edge_pos - !!ly*2 - (height<<3) - 4) { uint8_t *uvbuf = s->edge_emu_buffer + 22 * s->linesize; srcY -= 2 + 2*s->linesize; @@ -1097,6 +1102,7 @@ static int rv34_decode_macroblock(RV34DecContext *r, int8_t *intra_types) MpegEncContext *s = &r->s; GetBitContext *gb = &s->gb; int cbp, cbp2; + int q_dc, q_ac; int i, blknum, blkoff; LOCAL_ALIGNED_16(DCTELEM, block16, [64]); int luma_dc_quant; @@ -1133,31 +1139,34 @@ static int rv34_decode_macroblock(RV34DecContext *r, int8_t *intra_types) luma_dc_quant = r->block_type == RV34_MB_P_MIX16x16 ? r->luma_dc_quant_p[s->qscale] : r->luma_dc_quant_i[s->qscale]; if(r->is16){ + q_dc = rv34_qscale_tab[luma_dc_quant]; + q_ac = rv34_qscale_tab[s->qscale]; memset(block16, 0, 64 * sizeof(*block16)); - rv34_decode_block(block16, gb, r->cur_vlcs, 3, 0); - rv34_dequant4x4_16x16(block16, rv34_qscale_tab[luma_dc_quant],rv34_qscale_tab[s->qscale]); + rv34_decode_block(block16, gb, r->cur_vlcs, 3, 0, q_dc, q_dc, q_ac); r->rdsp.rv34_inv_transform_tab[1](block16); } + q_ac = rv34_qscale_tab[s->qscale]; for(i = 0; i < 16; i++, cbp >>= 1){ if(!r->is16 && !(cbp & 1)) continue; blknum = ((i & 2) >> 1) + ((i & 8) >> 2); blkoff = ((i & 1) << 2) + ((i & 4) << 3); if(cbp & 1) - rv34_decode_block(s->block[blknum] + blkoff, gb, r->cur_vlcs, r->luma_vlc, 0); - r->rdsp.rv34_dequant4x4(s->block[blknum] + blkoff, rv34_qscale_tab[s->qscale],rv34_qscale_tab[s->qscale]); + rv34_decode_block(s->block[blknum] + blkoff, gb, + r->cur_vlcs, r->luma_vlc, 0, q_ac, q_ac, q_ac); if(r->is16) //FIXME: optimize s->block[blknum][blkoff] = block16[(i & 3) | ((i & 0xC) << 1)]; r->rdsp.rv34_inv_transform_tab[0](s->block[blknum] + blkoff); } if(r->block_type == RV34_MB_P_MIX16x16) r->cur_vlcs = choose_vlc_set(r->si.quant, r->si.vlc_set, 1); + q_dc = rv34_qscale_tab[rv34_chroma_quant[1][s->qscale]]; + q_ac = rv34_qscale_tab[rv34_chroma_quant[0][s->qscale]]; for(; i < 24; i++, cbp >>= 1){ if(!(cbp & 1)) continue; blknum = ((i & 4) >> 2) + 4; blkoff = ((i & 1) << 2) + ((i & 2) << 4); - rv34_decode_block(s->block[blknum] + blkoff, gb, r->cur_vlcs, r->chroma_vlc, 1); - r->rdsp.rv34_dequant4x4(s->block[blknum] + blkoff, rv34_qscale_tab[rv34_chroma_quant[1][s->qscale]],rv34_qscale_tab[rv34_chroma_quant[0][s->qscale]]); + rv34_decode_block(s->block[blknum] + blkoff, gb, r->cur_vlcs, r->chroma_vlc, 1, q_dc, q_ac, q_ac); r->rdsp.rv34_inv_transform_tab[0](s->block[blknum] + blkoff); } if (IS_INTRA(s->current_picture_ptr->f.mb_type[mb_pos])) diff --git a/libavcodec/rv34data.h b/libavcodec/rv34data.h index 2155084d09..1b608e7e35 100644 --- a/libavcodec/rv34data.h +++ b/libavcodec/rv34data.h @@ -101,16 +101,6 @@ static const uint16_t rv34_qscale_tab[32] = { }; /** - * 4x4 dezigzag pattern - */ -static const uint8_t rv34_dezigzag[16] = { - 0, 1, 8, 16, - 9, 2, 3, 10, - 17, 24, 25, 18, - 11, 19, 26, 27 -}; - -/** * tables used to translate a quantizer value into a VLC set for decoding * The first table is used for intraframes. */ diff --git a/libavcodec/rv34dsp.c b/libavcodec/rv34dsp.c index 974bf9ec16..1f4cea8544 100644 --- a/libavcodec/rv34dsp.c +++ b/libavcodec/rv34dsp.c @@ -100,26 +100,10 @@ static void rv34_inv_transform_noround_c(DCTELEM *block){ /** @} */ // transform -/** - * Dequantize ordinary 4x4 block. - */ -void ff_rv34_dequant4x4_neon(DCTELEM *block, int Qdc, int Q); -static void rv34_dequant4x4_c(DCTELEM *block, int Qdc, int Q) -{ - int i, j; - - block[0] = (block[0] * Qdc + 8) >> 4; - for (i = 0; i < 4; i++) - for (j = !i; j < 4; j++) - block[j + i*8] = (block[j + i*8] * Q + 8) >> 4; -} - av_cold void ff_rv34dsp_init(RV34DSPContext *c, DSPContext* dsp) { c->rv34_inv_transform_tab[0] = rv34_inv_transform_c; c->rv34_inv_transform_tab[1] = rv34_inv_transform_noround_c; - c->rv34_dequant4x4 = rv34_dequant4x4_c; - if (HAVE_NEON) ff_rv34dsp_init_neon(c, dsp); } diff --git a/libavcodec/rv34dsp.h b/libavcodec/rv34dsp.h index 01352ea793..f2bc20e911 100644 --- a/libavcodec/rv34dsp.h +++ b/libavcodec/rv34dsp.h @@ -56,7 +56,6 @@ typedef struct RV34DSPContext { h264_chroma_mc_func avg_chroma_pixels_tab[3]; rv40_weight_func rv40_weight_pixels_tab[2]; rv34_inv_transform_func rv34_inv_transform_tab[2]; - void (*rv34_dequant4x4)(DCTELEM *block, int Qdc, int Q); rv40_weak_loop_filter_func rv40_weak_loop_filter[2]; rv40_strong_loop_filter_func rv40_strong_loop_filter[2]; rv40_loop_filter_strength_func rv40_loop_filter_strength[2]; diff --git a/libavcodec/ulti.c b/libavcodec/ulti.c index 4f0d90f665..6e7ba35f9d 100644 --- a/libavcodec/ulti.c +++ b/libavcodec/ulti.c @@ -38,16 +38,9 @@ typedef struct UltimotionDecodeContext { int width, height, blocks; AVFrame frame; const uint8_t *ulti_codebook; + GetByteContext gb; } UltimotionDecodeContext; -#define CHECK_OVERREAD_SIZE(size) \ - do { \ - if (buf_end - buf < (size)) { \ - av_log(avctx, AV_LOG_ERROR, "Insufficient data\n"); \ - return AVERROR_INVALIDDATA; \ - } \ - } while(0) - static av_cold int ulti_decode_init(AVCodecContext *avctx) { UltimotionDecodeContext *s = avctx->priv_data; @@ -232,7 +225,6 @@ static int ulti_decode_frame(AVCodecContext *avctx, int i; int skip; int tmp; - const uint8_t *buf_end = buf + buf_size; s->frame.reference = 3; s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; @@ -241,18 +233,20 @@ static int ulti_decode_frame(AVCodecContext *avctx, return -1; } + bytestream2_init(&s->gb, buf, buf_size); + while(!done) { int idx; if(blocks >= s->blocks || y >= s->height) break;//all blocks decoded - CHECK_OVERREAD_SIZE(1); - idx = *buf++; + if (bytestream2_get_bytes_left(&s->gb) < 1) + goto err; + idx = bytestream2_get_byteu(&s->gb); if((idx & 0xF8) == 0x70) { switch(idx) { case 0x70: //change modifier - CHECK_OVERREAD_SIZE(1); - modifier = *buf++; + modifier = bytestream2_get_byte(&s->gb); if(modifier>1) av_log(avctx, AV_LOG_INFO, "warning: modifier must be 0 or 1, got %i\n", modifier); break; @@ -266,8 +260,7 @@ static int ulti_decode_frame(AVCodecContext *avctx, done = 1; break; case 0x74: //skip some blocks - CHECK_OVERREAD_SIZE(1); - skip = *buf++; + skip = bytestream2_get_byte(&s->gb); if ((blocks + skip) >= s->blocks) break; blocks += skip; @@ -294,8 +287,7 @@ static int ulti_decode_frame(AVCodecContext *avctx, } else { cf = 0; if (idx) { - CHECK_OVERREAD_SIZE(1); - chroma = *buf++; + chroma = bytestream2_get_byte(&s->gb); } } for (i = 0; i < 4; i++) { // for every subblock @@ -303,15 +295,13 @@ static int ulti_decode_frame(AVCodecContext *avctx, if(!code) //skip subblock continue; if(cf) { - CHECK_OVERREAD_SIZE(1); - chroma = *buf++; + chroma = bytestream2_get_byte(&s->gb); } tx = x + block_coords[i * 2]; ty = y + block_coords[(i * 2) + 1]; switch(code) { case 1: - CHECK_OVERREAD_SIZE(1); - tmp = *buf++; + tmp = bytestream2_get_byte(&s->gb); angle = angle_by_index[(tmp >> 6) & 0x3]; @@ -331,8 +321,7 @@ static int ulti_decode_frame(AVCodecContext *avctx, case 2: if (modifier) { // unpack four luma samples - CHECK_OVERREAD_SIZE(3); - tmp = bytestream_get_be24(&buf); + tmp = bytestream2_get_be24(&s->gb); Y[0] = (tmp >> 18) & 0x3F; Y[1] = (tmp >> 12) & 0x3F; @@ -340,8 +329,7 @@ static int ulti_decode_frame(AVCodecContext *avctx, Y[3] = tmp & 0x3F; angle = 16; } else { // retrieve luma samples from codebook - CHECK_OVERREAD_SIZE(2); - tmp = bytestream_get_be16(&buf); + tmp = bytestream2_get_be16(&s->gb); angle = (tmp >> 12) & 0xF; tmp &= 0xFFF; @@ -357,27 +345,27 @@ static int ulti_decode_frame(AVCodecContext *avctx, if (modifier) { // all 16 luma samples uint8_t Luma[16]; - CHECK_OVERREAD_SIZE(12); - - tmp = bytestream_get_be24(&buf); + if (bytestream2_get_bytes_left(&s->gb) < 12) + goto err; + tmp = bytestream2_get_be24u(&s->gb); Luma[0] = (tmp >> 18) & 0x3F; Luma[1] = (tmp >> 12) & 0x3F; Luma[2] = (tmp >> 6) & 0x3F; Luma[3] = tmp & 0x3F; - tmp = bytestream_get_be24(&buf); + tmp = bytestream2_get_be24u(&s->gb); Luma[4] = (tmp >> 18) & 0x3F; Luma[5] = (tmp >> 12) & 0x3F; Luma[6] = (tmp >> 6) & 0x3F; Luma[7] = tmp & 0x3F; - tmp = bytestream_get_be24(&buf); + tmp = bytestream2_get_be24u(&s->gb); Luma[8] = (tmp >> 18) & 0x3F; Luma[9] = (tmp >> 12) & 0x3F; Luma[10] = (tmp >> 6) & 0x3F; Luma[11] = tmp & 0x3F; - tmp = bytestream_get_be24(&buf); + tmp = bytestream2_get_be24u(&s->gb); Luma[12] = (tmp >> 18) & 0x3F; Luma[13] = (tmp >> 12) & 0x3F; Luma[14] = (tmp >> 6) & 0x3F; @@ -385,22 +373,23 @@ static int ulti_decode_frame(AVCodecContext *avctx, ulti_convert_yuv(&s->frame, tx, ty, Luma, chroma); } else { - CHECK_OVERREAD_SIZE(4); - tmp = *buf++; + if (bytestream2_get_bytes_left(&s->gb) < 4) + goto err; + tmp = bytestream2_get_byteu(&s->gb); if(tmp & 0x80) { angle = (tmp >> 4) & 0x7; - tmp = (tmp << 8) + *buf++; + tmp = (tmp << 8) + bytestream2_get_byteu(&s->gb); Y[0] = (tmp >> 6) & 0x3F; Y[1] = tmp & 0x3F; - Y[2] = (*buf++) & 0x3F; - Y[3] = (*buf++) & 0x3F; + Y[2] = bytestream2_get_byteu(&s->gb) & 0x3F; + Y[3] = bytestream2_get_byteu(&s->gb) & 0x3F; ulti_grad(&s->frame, tx, ty, Y, chroma, angle); //draw block } else { // some patterns int f0, f1; - f0 = *buf++; + f0 = bytestream2_get_byteu(&s->gb); f1 = tmp; - Y[0] = (*buf++) & 0x3F; - Y[1] = (*buf++) & 0x3F; + Y[0] = bytestream2_get_byteu(&s->gb) & 0x3F; + Y[1] = bytestream2_get_byteu(&s->gb) & 0x3F; ulti_pattern(&s->frame, tx, ty, f1, f0, Y[0], Y[1], chroma); } } @@ -422,6 +411,11 @@ static int ulti_decode_frame(AVCodecContext *avctx, *(AVFrame*)data= s->frame; return buf_size; + +err: + av_log(avctx, AV_LOG_ERROR, + "Insufficient data\n"); + return AVERROR_INVALIDDATA; } AVCodec ff_ulti_decoder = { diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c index e4ecf14b5b..1469d815ce 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -568,6 +568,7 @@ static void vc1_mc_1mv(VC1Context *v, int dir) } if (v->rangeredfrm || (v->mv_mode == MV_PMODE_INTENSITY_COMP) + || s->h_edge_pos < 22 || v_edge_pos < 22 || (unsigned)(src_x - s->mspel) > s->h_edge_pos - (mx&3) - 16 - s->mspel * 3 || (unsigned)(src_y - s->mspel) > v_edge_pos - (my&3) - 16 - s->mspel * 3) { uint8_t *uvbuf = s->edge_emu_buffer + 19 * s->linesize; @@ -799,6 +800,7 @@ static void vc1_mc_4mv_luma(VC1Context *v, int n, int dir) if (fieldmv && (src_y & 1) && src_y < 4) src_y--; if (v->rangeredfrm || (v->mv_mode == MV_PMODE_INTENSITY_COMP) + || s->h_edge_pos < 13 || v_edge_pos < 23 || (unsigned)(src_x - s->mspel) > s->h_edge_pos - (mx & 3) - 8 - s->mspel * 2 || (unsigned)(src_y - (s->mspel << fieldmv)) > v_edge_pos - (my & 3) - ((8 + s->mspel * 2) << fieldmv)) { srcY -= s->mspel * (1 + (s->linesize << fieldmv)); @@ -998,6 +1000,7 @@ static void vc1_mc_4mv_chroma(VC1Context *v, int dir) } if (v->rangeredfrm || (v->mv_mode == MV_PMODE_INTENSITY_COMP) + || s->h_edge_pos < 18 || v_edge_pos < 18 || (unsigned)uvsrc_x > (s->h_edge_pos >> 1) - 9 || (unsigned)uvsrc_y > (v_edge_pos >> 1) - 9) { s->dsp.emulated_edge_mc(s->edge_emu_buffer , srcU, s->uvlinesize, @@ -1102,6 +1105,7 @@ static void vc1_mc_4mv_chroma4(VC1Context *v) if (fieldmv && (uvsrc_y & 1) && uvsrc_y < 2) uvsrc_y--; if ((v->mv_mode == MV_PMODE_INTENSITY_COMP) + || s->h_edge_pos < 10 || v_edge_pos < (5 << fieldmv) || (unsigned)uvsrc_x > (s->h_edge_pos >> 1) - 5 || (unsigned)uvsrc_y > v_edge_pos - (5 << fieldmv)) { s->dsp.emulated_edge_mc(s->edge_emu_buffer, srcU, s->uvlinesize, @@ -2006,7 +2010,7 @@ static void vc1_interp_mc(VC1Context *v) srcV = s->edge_emu_buffer + 18 * s->linesize; } - if (v->rangeredfrm + if (v->rangeredfrm || s->h_edge_pos < 22 || v_edge_pos < 22 || (unsigned)(src_x - s->mspel) > s->h_edge_pos - (mx & 3) - 16 - s->mspel * 3 || (unsigned)(src_y - s->mspel) > v_edge_pos - (my & 3) - 16 - s->mspel * 3) { uint8_t *uvbuf = s->edge_emu_buffer + 19 * s->linesize; |