History

Merge remote branch 'qatar/master'

* qatar/master: (23 commits) doc: Check standalone compilation before submitting new components. Fix standalone compilation of pipe protocol. Fix standalone compilation of ac3_fixed encoder. Fix standalone compilation of binkaudio_dct / binkaudio_rdft decoders. Fix standalone compilation of IMC decoder. Fix standalone compilation of WTV demuxer. Fix standalone compilation of MXPEG decoder. flashsv: K&R cosmetics matroskaenc: fix memory leak vc1: make overlap filter for I-frames bit-exact. vc1dec: use s->start/end_mb_y instead of passing them as function args. Revert "VC1: merge idct8x8, coeff adjustments and put_pixels." Replace strncpy() with av_strlcpy(). indeo3: Eliminate use of long. get_bits: make cache unsigned to eliminate undefined signed overflow. asfdec: fix assert failure on invalid files avfilter: check malloc return values. Not pulled as reason for reindent is not pulled: mpegvideo: reindent. nutenc: check malloc return values. Not pulled due to much simpler solution in ffmpeg *: don't av_malloc(0). ... Conflicts: doc/developer.texi libavcodec/Makefile libavcodec/get_bits.h libavcodec/mpegvideo.c libavformat/Makefile libavutil/log.c

Michael Niedermayer committed 15 years ago

Commit b000b862 parents 9a5624a af1ca2425 files · +490 −319Browse files

Unified · Split

25 files
  1. configure +4 −4
  2. doc/developer.texi +6 −1
  3. ffmpeg.c +1 −2
  4. libavcodec/Makefile +2 −1
  5. libavcodec/ac3enc.c +22 −21
  6. libavcodec/ass.c +2 −2
  7. libavcodec/flashsv.c +2 −2
  8. libavcodec/get_bits.h +1 −1
  9. libavcodec/indeo3.c +11 −11
  10. libavcodec/ppc/vc1dsp_altivec.c +2 −61
  11. libavcodec/vc1.c +1 −27
  12. libavcodec/vc1.h +2 −0
  13. libavcodec/vc1dec.c +284 −98
  14. libavcodec/vc1dsp.c +64 −44
  15. libavcodec/vc1dsp.h +5 −7
  16. libavfilter/avfilter.c +26 −1
  17. libavformat/Makefile +2 −1
  18. libavformat/asfdec.c +12 −2
  19. libavformat/file.c +13 −13
  20. libavformat/matroskaenc.c +2 −2
  21. libavformat/movenc.c +1 −1
  22. libavformat/mp3enc.c +2 −1
  23. libavformat/nutenc.c +6 −0
  24. libpostproc/postprocess.c +2 −1
  25. tests/ref/fate/vc1 +15 −15
configure+4−4
@@ -1252,14 +1252,14 @@ aac_encoder_select="mdct sinewin" · 1251 unmodified lines
12521252 aac_latm_decoder_select="aac_decoder aac_latm_parser"
12531253 ac3_decoder_select="mdct ac3dsp ac3_parser"
12541254 ac3_encoder_select="mdct ac3dsp"
1255−ac3_fixed_encoder_select="ac3dsp"
1255+ac3_fixed_encoder_select="mdct ac3dsp"
12561256 alac_encoder_select="lpc"
12571257 amrnb_decoder_select="lsp"
12581258 amrwb_decoder_select="lsp"
12591259 atrac1_decoder_select="mdct sinewin"
12601260 atrac3_decoder_select="mdct"
1261−binkaudio_dct_decoder_select="mdct rdft dct"
1262−binkaudio_rdft_decoder_select="mdct rdft"
1261+binkaudio_dct_decoder_select="mdct rdft dct sinewin"
1262+binkaudio_rdft_decoder_select="mdct rdft sinewin"
12631263 cavs_decoder_select="golomb"
12641264 cook_decoder_select="mdct sinewin"
12651265 cscd_decoder_suggest="zlib"
@@ -1291,7 +1291,7 @@ h264_dxva2_hwaccel_deps="dxva2api_h" · 25 unmodified lines
12911291 h264_dxva2_hwaccel_select="dxva2 h264_decoder"
12921292 h264_vaapi_hwaccel_select="vaapi"
12931293 h264_vdpau_decoder_select="vdpau h264_decoder"
1294−imc_decoder_select="fft mdct"
1294+imc_decoder_select="fft mdct sinewin"
12951295 jpegls_decoder_select="golomb"
12961296 jpegls_encoder_select="golomb"
12971297 ljpeg_encoder_select="aandct"
doc/developer.texi+6−1
@@ -312,9 +312,14 @@ send a reminder by email. Your patch should eventually be dealt with. · 311 unmodified lines
312312 If it depends on a parser or a library, did you add that dependency in
313313 configure?
314314 @item
315− Did you "git add" the appropriate files before committing?
315+ Did you @code{git add} the appropriate files before committing?
316+@item
317+ Did you make sure it compiles standalone, i.e. with
318+ @code{configure --disable-everything --enable-decoder=foo}
319+ (or @code{--enable-demuxer} or whatever your component is)?
316320 @end enumerate
317321
322+
318323 @section patch submission checklist
319324
320325 @enumerate
ffmpeg.c+1−2
@@ -3816,8 +3816,7 @@ static int opt_streamid(const char *opt, const char *arg) · 3815 unmodified lines
38163816 char *p;
38173817 char idx_str[16];
38183818
3819− strncpy(idx_str, arg, sizeof(idx_str));
3820− idx_str[sizeof(idx_str)-1] = '\0';
3819+ av_strlcpy(idx_str, arg, sizeof(idx_str));
38213820 p = strchr(idx_str, ':');
38223821 if (!p) {
38233822 fprintf(stderr,
libavcodec/Makefile+2−1
@@ -277,7 +277,7 @@ OBJS-$(CONFIG_MSRLE_DECODER) += msrle.o msrledec.o · 276 unmodified lines
277277 OBJS-$(CONFIG_MSVIDEO1_DECODER) += msvideo1.o
278278 OBJS-$(CONFIG_MSVIDEO1_ENCODER) += msvideo1enc.o elbg.o
279279 OBJS-$(CONFIG_MSZH_DECODER) += lcldec.o
280−OBJS-$(CONFIG_MXPEG_DECODER) += mxpegdec.o
280+OBJS-$(CONFIG_MXPEG_DECODER) += mxpegdec.o mjpegdec.o mjpeg.o
281281 OBJS-$(CONFIG_NELLYMOSER_DECODER) += nellymoserdec.o nellymoser.o
282282 OBJS-$(CONFIG_NELLYMOSER_ENCODER) += nellymoserenc.o nellymoser.o
283283 OBJS-$(CONFIG_NUV_DECODER) += nuv.o rtjpeg.o
@@ -556,6 +556,7 @@ OBJS-$(CONFIG_SPDIF_DEMUXER) += aacadtsdec.o mpeg4audio.o · 272 unmodified lines
556556 OBJS-$(CONFIG_WEBM_MUXER) += xiph.o mpeg4audio.o \
557557 flacdec.o flacdata.o flac.o \
558558 mpegaudiodata.o vorbis_data.o
559+OBJS-$(CONFIG_WTV_DEMUXER) += mpeg4audio.o mpegaudiodata.o
559560
560561 # external codec libraries
561562 OBJS-$(CONFIG_LIBCELT_DECODER) += libcelt_dec.o
libavcodec/ac3enc.c+22−21
@@ -33,6 +33,7 @@ · 32 unmodified lines
3333
3434 #include "libavutil/audioconvert.h"
3535 #include "libavutil/avassert.h"
36+#include "libavutil/avstring.h"
3637 #include "libavutil/crc.h"
3738 #include "libavutil/opt.h"
3839 #include "avcodec.h"
@@ -1551,10 +1552,10 @@ static void dprint_options(AVCodecContext *avctx) · 1512 unmodified lines
15511552 char strbuf[32];
15521553
15531554 switch (s->bitstream_id) {
1554− case 6: strncpy(strbuf, "AC-3 (alt syntax)", 32); break;
1555− case 8: strncpy(strbuf, "AC-3 (standard)", 32); break;
1556− case 9: strncpy(strbuf, "AC-3 (dnet half-rate)", 32); break;
1557− case 10: strncpy(strbuf, "AC-3 (dnet quater-rate", 32); break;
1555+ case 6: av_strlcpy(strbuf, "AC-3 (alt syntax)", 32); break;
1556+ case 8: av_strlcpy(strbuf, "AC-3 (standard)", 32); break;
1557+ case 9: av_strlcpy(strbuf, "AC-3 (dnet half-rate)", 32); break;
1558+ case 10: av_strlcpy(strbuf, "AC-3 (dnet quater-rate", 32); break;
15581559 default: snprintf(strbuf, 32, "ERROR");
15591560 }
15601561 av_dlog(avctx, "bitstream_id: %s (%d)\n", strbuf, s->bitstream_id);
@@ -1581,9 +1582,9 @@ static void dprint_options(AVCodecContext *avctx) · 20 unmodified lines
15811582 if (opt->audio_production_info) {
15821583 av_dlog(avctx, "mixing_level: %ddB\n", opt->mixing_level);
15831584 switch (opt->room_type) {
1584− case 0: strncpy(strbuf, "notindicated", 32); break;
1585− case 1: strncpy(strbuf, "large", 32); break;
1586− case 2: strncpy(strbuf, "small", 32); break;
1585+ case 0: av_strlcpy(strbuf, "notindicated", 32); break;
1586+ case 1: av_strlcpy(strbuf, "large", 32); break;
1587+ case 2: av_strlcpy(strbuf, "small", 32); break;
15871588 default: snprintf(strbuf, 32, "ERROR (%d)", opt->room_type);
15881589 }
15891590 av_dlog(avctx, "room_type: %s\n", strbuf);
@@ -1595,9 +1596,9 @@ static void dprint_options(AVCodecContext *avctx) · 5 unmodified lines
15951596 av_dlog(avctx, "dialnorm: %ddB\n", opt->dialogue_level);
15961597 if (s->channel_mode == AC3_CHMODE_STEREO) {
15971598 switch (opt->dolby_surround_mode) {
1598− case 0: strncpy(strbuf, "notindicated", 32); break;
1599− case 1: strncpy(strbuf, "on", 32); break;
1600− case 2: strncpy(strbuf, "off", 32); break;
1599+ case 0: av_strlcpy(strbuf, "notindicated", 32); break;
1600+ case 1: av_strlcpy(strbuf, "on", 32); break;
1601+ case 2: av_strlcpy(strbuf, "off", 32); break;
16011602 default: snprintf(strbuf, 32, "ERROR (%d)", opt->dolby_surround_mode);
16021603 }
16031604 av_dlog(avctx, "dsur_mode: %s\n", strbuf);
@@ -1609,9 +1610,9 @@ static void dprint_options(AVCodecContext *avctx) · 5 unmodified lines
16091610 if (s->bitstream_id == 6) {
16101611 if (opt->extended_bsi_1) {
16111612 switch (opt->preferred_stereo_downmix) {
1612− case 0: strncpy(strbuf, "notindicated", 32); break;
1613− case 1: strncpy(strbuf, "ltrt", 32); break;
1614− case 2: strncpy(strbuf, "loro", 32); break;
1613+ case 0: av_strlcpy(strbuf, "notindicated", 32); break;
1614+ case 1: av_strlcpy(strbuf, "ltrt", 32); break;
1615+ case 2: av_strlcpy(strbuf, "loro", 32); break;
16151616 default: snprintf(strbuf, 32, "ERROR (%d)", opt->preferred_stereo_downmix);
16161617 }
16171618 av_dlog(avctx, "dmix_mode: %s\n", strbuf);
@@ -1628,23 +1629,23 @@ static void dprint_options(AVCodecContext *avctx) · 10 unmodified lines
16281629 }
16291630 if (opt->extended_bsi_2) {
16301631 switch (opt->dolby_surround_ex_mode) {
1631− case 0: strncpy(strbuf, "notindicated", 32); break;
1632− case 1: strncpy(strbuf, "on", 32); break;
1633− case 2: strncpy(strbuf, "off", 32); break;
1632+ case 0: av_strlcpy(strbuf, "notindicated", 32); break;
1633+ case 1: av_strlcpy(strbuf, "on", 32); break;
1634+ case 2: av_strlcpy(strbuf, "off", 32); break;
16341635 default: snprintf(strbuf, 32, "ERROR (%d)", opt->dolby_surround_ex_mode);
16351636 }
16361637 av_dlog(avctx, "dsurex_mode: %s\n", strbuf);
16371638 switch (opt->dolby_headphone_mode) {
1638− case 0: strncpy(strbuf, "notindicated", 32); break;
1639− case 1: strncpy(strbuf, "on", 32); break;
1640− case 2: strncpy(strbuf, "off", 32); break;
1639+ case 0: av_strlcpy(strbuf, "notindicated", 32); break;
1640+ case 1: av_strlcpy(strbuf, "on", 32); break;
1641+ case 2: av_strlcpy(strbuf, "off", 32); break;
16411642 default: snprintf(strbuf, 32, "ERROR (%d)", opt->dolby_headphone_mode);
16421643 }
16431644 av_dlog(avctx, "dheadphone_mode: %s\n", strbuf);
16441645
16451646 switch (opt->ad_converter_type) {
1646− case 0: strncpy(strbuf, "standard", 32); break;
1647− case 1: strncpy(strbuf, "hdcd", 32); break;
1647+ case 0: av_strlcpy(strbuf, "standard", 32); break;
1648+ case 1: av_strlcpy(strbuf, "hdcd", 32); break;
16481649 default: snprintf(strbuf, 32, "ERROR (%d)", opt->ad_converter_type);
16491650 }
16501651 av_dlog(avctx, "ad_conv_type: %s\n", strbuf);
libavcodec/ass.c+2−2
@@ -21,6 +21,7 @@ · 20 unmodified lines
2121
2222 #include "avcodec.h"
2323 #include "ass.h"
24+#include "libavutil/avstring.h"
2425
2526 int ff_ass_subtitle_header(AVCodecContext *avctx,
2627 const char *font, int font_size,
@@ -97,8 +98,7 @@ int ff_ass_add_rect(AVSubtitle *sub, const char *dialog, · 70 unmodified lines
9798 rects[sub->num_rects]->type = SUBTITLE_ASS;
9899 rects[sub->num_rects]->ass = av_malloc(len + dlen + 1);
99100 strcpy (rects[sub->num_rects]->ass , header);
100− strncpy(rects[sub->num_rects]->ass + len, dialog, dlen);
101− rects[sub->num_rects]->ass[len+dlen] = 0;
101+ av_strlcpy(rects[sub->num_rects]->ass + len, dialog, dlen + 1);
102102 sub->num_rects++;
103103 return dlen;
104104 }
libavcodec/flashsv.c+2−2
@@ -148,7 +148,7 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, · 147 unmodified lines
148148 if ((avctx->width != s->image_width) || (avctx->height != s->image_height)) {
149149 av_log(avctx, AV_LOG_ERROR, "Frame width or height differs from first frames!\n");
150150 av_log(avctx, AV_LOG_ERROR, "fh = %d, fv %d vs ch = %d, cv = %d\n", avctx->height,
151− avctx->width,s->image_height, s->image_width);
151+ avctx->width, s->image_height, s->image_width);
152152 return -1;
153153 }
154154
@@ -195,7 +195,7 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, · 40 unmodified lines
195195 s->zstream.next_in = buf + (get_bits_count(&gb) / 8);
196196 s->zstream.avail_in = size;
197197 s->zstream.next_out = s->tmpblock;
198− s->zstream.avail_out = s->block_size*3;
198+ s->zstream.avail_out = s->block_size * 3;
199199 ret = inflate(&(s->zstream), Z_FINISH);
200200 if (ret == Z_DATA_ERROR) {
201201 av_log(avctx, AV_LOG_ERROR, "Zlib resync occurred\n");
libavcodec/get_bits.h+1−1
@@ -127,7 +127,7 @@ for examples see get_bits, show_bits, skip_bits, get_vlc · 126 unmodified lines
127127
128128 # define OPEN_READER(name, gb) \
129129 unsigned int name##_index = (gb)->index; \
130− av_unused int name##_cache
130+ av_unused unsigned int name##_cache
131131
132132 # define CLOSE_READER(name, gb) (gb)->index = name##_index
133133
libavcodec/indeo3.c+11−11
@@ -149,13 +149,13 @@ static av_cold void iv_free_func(Indeo3DecodeContext *s) · 148 unmodified lines
149149 }
150150
151151 struct ustr {
152− long xpos;
153− long ypos;
154− long width;
155− long height;
156− long split_flag;
157− long split_direction;
158− long usl7;
152+ int xpos;
153+ int ypos;
154+ int width;
155+ int height;
156+ int split_flag;
157+ int split_direction;
158+ int usl7;
159159 };
160160
161161
@@ -203,12 +203,12 @@ struct ustr { · 41 unmodified lines
203203
204204 static void iv_Decode_Chunk(Indeo3DecodeContext *s,
205205 uint8_t *cur, uint8_t *ref, int width, int height,
206− const uint8_t *buf1, long cb_offset, const uint8_t *hdr,
206+ const uint8_t *buf1, int cb_offset, const uint8_t *hdr,
207207 const uint8_t *buf2, int min_width_160)
208208 {
209209 uint8_t bit_buf;
210− unsigned long bit_pos, lv, lv1, lv2;
211− long *width_tbl, width_tbl_arr[10];
210+ unsigned int bit_pos, lv, lv1, lv2;
211+ int *width_tbl, width_tbl_arr[10];
212212 const signed char *ref_vectors;
213213 uint8_t *cur_frm_pos, *ref_frm_pos, *cp, *cp2;
214214 uint32_t *cur_lp, *ref_lp;
@@ -982,7 +982,7 @@ static int iv_decode_frame(AVCodecContext *avctx, · 767 unmodified lines
982982 Indeo3DecodeContext *s = avctx->priv_data;
983983 unsigned int image_width, image_height,
984984 chroma_width, chroma_height;
985− unsigned long flags, cb_offset, data_size,
985+ unsigned int flags, cb_offset, data_size,
986986 y_offset, v_offset, u_offset, mc_vector_count;
987987 const uint8_t *hdr_pos, *buf_pos;
988988
libavcodec/ppc/vc1dsp_altivec.c+2−61
@@ -130,8 +130,7 @@ do { \ · 129 unmodified lines
130130
131131 /** Do inverse transform on 8x8 block
132132 */
133−static void vc1_inv_trans_8x8_altivec(DCTELEM block[64],
134− int sign, int rangered)
133+static void vc1_inv_trans_8x8_altivec(DCTELEM block[64])
135134 {
136135 vector signed short src0, src1, src2, src3, src4, src5, src6, src7;
137136 vector signed int s0, s1, s2, s3, s4, s5, s6, s7;
@@ -145,9 +144,6 @@ static void vc1_inv_trans_8x8_altivec(DCTELEM block[64], · 7 unmodified lines
145144 const vector unsigned int vec_2 = vec_splat_u32(2);
146145 const vector signed int vec_1s = vec_splat_s32(1);
147146 const vector unsigned int vec_1 = vec_splat_u32(1);
148− const vector unsigned short rangered_shift = vec_splat_u16(1);
149− const vector signed short signed_bias = vec_sl(vec_splat_s16(4),
150− vec_splat_u16(4));
151147
152148 src0 = vec_ld( 0, block);
153149 src1 = vec_ld( 16, block);
@@ -217,27 +213,6 @@ static void vc1_inv_trans_8x8_altivec(DCTELEM block[64], · 63 unmodified lines
217213 src6 = vec_pack(sE, s6);
218214 src7 = vec_pack(sF, s7);
219215
220− if (rangered) {
221− if (!sign) {
222− src0 = vec_sub(src0, signed_bias);
223− src1 = vec_sub(src1, signed_bias);
224− src2 = vec_sub(src2, signed_bias);
225− src3 = vec_sub(src3, signed_bias);
226− src4 = vec_sub(src4, signed_bias);
227− src5 = vec_sub(src5, signed_bias);
228− src6 = vec_sub(src6, signed_bias);
229− src7 = vec_sub(src7, signed_bias);
230− }
231− src0 = vec_sl(src0, rangered_shift);
232− src1 = vec_sl(src1, rangered_shift);
233− src2 = vec_sl(src2, rangered_shift);
234− src3 = vec_sl(src3, rangered_shift);
235− src4 = vec_sl(src4, rangered_shift);
236− src5 = vec_sl(src5, rangered_shift);
237− src6 = vec_sl(src6, rangered_shift);
238− src7 = vec_sl(src7, rangered_shift);
239− }
240−
241216 vec_st(src0, 0, block);
242217 vec_st(src1, 16, block);
243218 vec_st(src2, 32, block);
@@ -248,36 +223,6 @@ static void vc1_inv_trans_8x8_altivec(DCTELEM block[64], · 4 unmodified lines
248223 vec_st(src7,112, block);
249224 }
250225
251−static void vc1_inv_trans_8x8_add_altivec(uint8_t *dest, int stride, DCTELEM *b)
252−{
253− vc1_inv_trans_8x8_altivec(b, 0, 0);
254− ff_add_pixels_clamped_c(b, dest, stride);
255−}
256−
257−static void vc1_inv_trans_8x8_put_signed_altivec(uint8_t *dest, int stride, DCTELEM *b)
258−{
259− vc1_inv_trans_8x8_altivec(b, 1, 0);
260− ff_put_signed_pixels_clamped_c(b, dest, stride);
261−}
262−
263−static void vc1_inv_trans_8x8_put_signed_rangered_altivec(uint8_t *dest, int stride, DCTELEM *b)
264−{
265− vc1_inv_trans_8x8_altivec(b, 1, 1);
266− ff_put_signed_pixels_clamped_c(b, dest, stride);
267−}
268−
269−static void vc1_inv_trans_8x8_put_altivec(uint8_t *dest, int stride, DCTELEM *b)
270−{
271− vc1_inv_trans_8x8_altivec(b, 0, 0);
272− ff_put_pixels_clamped_c(b, dest, stride);
273−}
274−
275−static void vc1_inv_trans_8x8_put_rangered_altivec(uint8_t *dest, int stride, DCTELEM *b)
276−{
277− vc1_inv_trans_8x8_altivec(b, 0, 1);
278− ff_put_pixels_clamped_c(b, dest, stride);
279−}
280−
281226 /** Do inverse transform on 8x4 part of block
282227 */
283228 static void vc1_inv_trans_8x4_altivec(uint8_t *dest, int stride, DCTELEM *block)
@@ -396,11 +341,7 @@ void ff_vc1dsp_init_altivec(VC1DSPContext* dsp) · 112 unmodified lines
396341 if (!(av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC))
397342 return;
398343
399− dsp->vc1_inv_trans_8x8_add = vc1_inv_trans_8x8_add_altivec;
400− dsp->vc1_inv_trans_8x8_put_signed[0] = vc1_inv_trans_8x8_put_signed_altivec;
401− dsp->vc1_inv_trans_8x8_put_signed[1] = vc1_inv_trans_8x8_put_signed_rangered_altivec;
402− dsp->vc1_inv_trans_8x8_put[0] = vc1_inv_trans_8x8_put_altivec;
403− dsp->vc1_inv_trans_8x8_put[1] = vc1_inv_trans_8x8_put_rangered_altivec;
344+ dsp->vc1_inv_trans_8x8 = vc1_inv_trans_8x8_altivec;
404345 dsp->vc1_inv_trans_8x4 = vc1_inv_trans_8x4_altivec;
405346 dsp->put_no_rnd_vc1_chroma_pixels_tab[0] = put_no_rnd_vc1_chroma_mc8_altivec;
406347 dsp->avg_no_rnd_vc1_chroma_pixels_tab[0] = avg_no_rnd_vc1_chroma_mc8_altivec;
libavcodec/vc1.c+1−27
@@ -280,28 +280,6 @@ static int vop_dquant_decoding(VC1Context *v) · 279 unmodified lines
280280
281281 static int decode_sequence_header_adv(VC1Context *v, GetBitContext *gb);
282282
283−static void simple_idct_put_rangered(uint8_t *dest, int line_size, DCTELEM *block)
284−{
285− int i;
286− ff_simple_idct(block);
287− for (i = 0; i < 64; i++) block[i] = (block[i] - 64) << 1;
288− ff_put_pixels_clamped_c(block, dest, line_size);
289−}
290−
291−static void simple_idct_put_signed(uint8_t *dest, int line_size, DCTELEM *block)
292−{
293− ff_simple_idct(block);
294− ff_put_signed_pixels_clamped_c(block, dest, line_size);
295−}
296−
297−static void simple_idct_put_signed_rangered(uint8_t *dest, int line_size, DCTELEM *block)
298−{
299− int i;
300− ff_simple_idct(block);
301− for (i = 0; i < 64; i++) block[i] <<= 1;
302− ff_put_signed_pixels_clamped_c(block, dest, line_size);
303−}
304−
305283 /**
306284 * Decode Simple/Main Profiles sequence header
307285 * @see Figure 7-8, p16-17
@@ -359,11 +337,7 @@ int vc1_decode_sequence_header(AVCodecContext *avctx, VC1Context *v, GetBitConte · 51 unmodified lines
359337 v->res_fasttx = get_bits1(gb);
360338 if (!v->res_fasttx)
361339 {
362− v->vc1dsp.vc1_inv_trans_8x8_add = ff_simple_idct_add;
363− v->vc1dsp.vc1_inv_trans_8x8_put[0] = ff_simple_idct_put;
364− v->vc1dsp.vc1_inv_trans_8x8_put[1] = simple_idct_put_rangered;
365− v->vc1dsp.vc1_inv_trans_8x8_put_signed[0] = simple_idct_put_signed;
366− v->vc1dsp.vc1_inv_trans_8x8_put_signed[1] = simple_idct_put_signed_rangered;
340+ v->vc1dsp.vc1_inv_trans_8x8 = ff_simple_idct;
367341 v->vc1dsp.vc1_inv_trans_8x4 = ff_simple_idct84_add;
368342 v->vc1dsp.vc1_inv_trans_4x8 = ff_simple_idct48_add;
369343 v->vc1dsp.vc1_inv_trans_4x4 = ff_simple_idct44_add;
libavcodec/vc1.h+2−0
@@ -317,6 +317,8 @@ typedef struct VC1Context{ · 316 unmodified lines
317317 int bi_type;
318318 int x8_type;
319319
320+ DCTELEM (*block)[6][64];
321+ int n_allocated_blks, cur_blk_idx, left_blk_idx, topleft_blk_idx, top_blk_idx;
320322 uint32_t *cbp_base, *cbp;
321323 uint8_t *is_intra_base, *is_intra;
322324 int16_t (*luma_mv_base)[2], (*luma_mv)[2];
libavcodec/vc1dec.c+284−98
@@ -160,6 +160,72 @@ enum Imode { · 159 unmodified lines
160160
161161 /** @} */ //Bitplane group
162162
163+static void vc1_put_signed_blocks_clamped(VC1Context *v)
164+{
165+ MpegEncContext *s = &v->s;
166+
167+ /* The put pixels loop is always one MB row behind the decoding loop,
168+ * because we can only put pixels when overlap filtering is done, and
169+ * for filtering of the bottom edge of a MB, we need the next MB row
170+ * present as well.
171+ * Within the row, the put pixels loop is also one MB col behind the
172+ * decoding loop. The reason for this is again, because for filtering
173+ * of the right MB edge, we need the next MB present. */
174+ if (!s->first_slice_line) {
175+ if (s->mb_x) {
176+ s->dsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][0],
177+ s->dest[0] - 16 * s->linesize - 16,
178+ s->linesize);
179+ s->dsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][1],
180+ s->dest[0] - 16 * s->linesize - 8,
181+ s->linesize);
182+ s->dsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][2],
183+ s->dest[0] - 8 * s->linesize - 16,
184+ s->linesize);
185+ s->dsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][3],
186+ s->dest[0] - 8 * s->linesize - 8,
187+ s->linesize);
188+ s->dsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][4],
189+ s->dest[1] - 8 * s->uvlinesize - 8,
190+ s->uvlinesize);
191+ s->dsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][5],
192+ s->dest[2] - 8 * s->uvlinesize - 8,
193+ s->uvlinesize);
194+ }
195+ if (s->mb_x == s->mb_width - 1) {
196+ s->dsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][0],
197+ s->dest[0] - 16 * s->linesize,
198+ s->linesize);
199+ s->dsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][1],
200+ s->dest[0] - 16 * s->linesize + 8,
201+ s->linesize);
202+ s->dsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][2],
203+ s->dest[0] - 8 * s->linesize,
204+ s->linesize);
205+ s->dsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][3],
206+ s->dest[0] - 8 * s->linesize + 8,
207+ s->linesize);
208+ s->dsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][4],
209+ s->dest[1] - 8 * s->uvlinesize,
210+ s->uvlinesize);
211+ s->dsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][5],
212+ s->dest[2] - 8 * s->uvlinesize,
213+ s->uvlinesize);
214+ }
215+ }
216+
217+#define inc_blk_idx(idx) do { \
218+ idx++; \
219+ if (idx >= v->n_allocated_blks) \
220+ idx = 0; \
221+ } while (0)
222+
223+ inc_blk_idx(v->topleft_blk_idx);
224+ inc_blk_idx(v->top_blk_idx);
225+ inc_blk_idx(v->left_blk_idx);
226+ inc_blk_idx(v->cur_blk_idx);
227+}
228+
163229 static void vc1_loop_filter_iblk(VC1Context *v, int pq)
164230 {
165231 MpegEncContext *s = &v->s;
@@ -187,6 +253,151 @@ static void vc1_loop_filter_iblk(VC1Context *v, int pq) · 21 unmodified lines
187253 }
188254 }
189255
256+static void vc1_loop_filter_iblk_delayed(VC1Context *v, int pq)
257+{
258+ MpegEncContext *s = &v->s;
259+ int j;
260+
261+ /* The loopfilter runs 1 row and 1 column behind the overlap filter, which
262+ * means it runs two rows/cols behind the decoding loop. */
263+ if (!s->first_slice_line) {
264+ if (s->mb_x) {
265+ if (s->mb_y >= s->start_mb_y + 2) {
266+ v->vc1dsp.vc1_v_loop_filter16(s->dest[0] - 16 * s->linesize - 16, s->linesize, pq);
267+
268+ if (s->mb_x >= 2)
269+ v->vc1dsp.vc1_h_loop_filter16(s->dest[0] - 32 * s->linesize - 16, s->linesize, pq);
270+ v->vc1dsp.vc1_h_loop_filter16(s->dest[0] - 32 * s->linesize - 8, s->linesize, pq);
271+ for(j = 0; j < 2; j++) {
272+ v->vc1dsp.vc1_v_loop_filter8(s->dest[j+1] - 8 * s->uvlinesize - 8, s->uvlinesize, pq);
273+ if (s->mb_x >= 2) {
274+ v->vc1dsp.vc1_h_loop_filter8(s->dest[j+1] - 16 * s->uvlinesize - 8, s->uvlinesize, pq);
275+ }
276+ }
277+ }
278+ v->vc1dsp.vc1_v_loop_filter16(s->dest[0] - 8 * s->linesize - 16, s->linesize, pq);
279+ }
280+
281+ if (s->mb_x == s->mb_width - 1) {
282+ if (s->mb_y >= s->start_mb_y + 2) {
283+ v->vc1dsp.vc1_v_loop_filter16(s->dest[0] - 16 * s->linesize, s->linesize, pq);
284+
285+ if (s->mb_x)
286+ v->vc1dsp.vc1_h_loop_filter16(s->dest[0] - 32 * s->linesize, s->linesize, pq);
287+ v->vc1dsp.vc1_h_loop_filter16(s->dest[0] - 32 * s->linesize + 8, s->linesize, pq);
288+ for(j = 0; j < 2; j++) {
289+ v->vc1dsp.vc1_v_loop_filter8(s->dest[j+1] - 8 * s->uvlinesize, s->uvlinesize, pq);
290+ if (s->mb_x >= 2) {
291+ v->vc1dsp.vc1_h_loop_filter8(s->dest[j+1] - 16 * s->uvlinesize, s->uvlinesize, pq);
292+ }
293+ }
294+ }
295+ v->vc1dsp.vc1_v_loop_filter16(s->dest[0] - 8 * s->linesize, s->linesize, pq);
296+ }
297+
298+ if (s->mb_y == s->mb_height) {
299+ if (s->mb_x) {
300+ if (s->mb_x >= 2)
301+ v->vc1dsp.vc1_h_loop_filter16(s->dest[0] - 16 * s->linesize - 16, s->linesize, pq);
302+ v->vc1dsp.vc1_h_loop_filter16(s->dest[0] - 16 * s->linesize - 8, s->linesize, pq);
303+ if (s->mb_x >= 2) {
304+ for(j = 0; j < 2; j++) {
305+ v->vc1dsp.vc1_h_loop_filter8(s->dest[j+1] - 8 * s->uvlinesize - 8, s->uvlinesize, pq);
306+ }
307+ }
308+ }
309+
310+ if (s->mb_x == s->mb_width - 1) {
311+ if (s->mb_x)
312+ v->vc1dsp.vc1_h_loop_filter16(s->dest[0] - 16 * s->linesize, s->linesize, pq);
313+ v->vc1dsp.vc1_h_loop_filter16(s->dest[0] - 16 * s->linesize + 8, s->linesize, pq);
314+ if (s->mb_x) {
315+ for(j = 0; j < 2; j++) {
316+ v->vc1dsp.vc1_h_loop_filter8(s->dest[j+1] - 8 * s->uvlinesize, s->uvlinesize, pq);
317+ }
318+ }
319+ }
320+ }
321+ }
322+}
323+
324+static void vc1_smooth_overlap_filter_iblk(VC1Context *v)
325+{
326+ MpegEncContext *s = &v->s;
327+ int mb_pos;
328+
329+ if (v->condover == CONDOVER_NONE)
330+ return;
331+
332+ mb_pos = s->mb_x + s->mb_y * s->mb_stride;
333+
334+ /* Within a MB, the horizontal overlap always runs before the vertical.
335+ * To accomplish that, we run the H on left and internal borders of the
336+ * currently decoded MB. Then, we wait for the next overlap iteration
337+ * to do H overlap on the right edge of this MB, before moving over and
338+ * running the V overlap. Therefore, the V overlap makes us trail by one
339+ * MB col and the H overlap filter makes us trail by one MB row. This
340+ * is reflected in the time at which we run the put_pixels loop. */
341+ if(v->condover == CONDOVER_ALL || v->pq >= 9 || v->over_flags_plane[mb_pos]) {
342+ if(s->mb_x && (v->condover == CONDOVER_ALL || v->pq >= 9 ||
343+ v->over_flags_plane[mb_pos - 1])) {
344+ v->vc1dsp.vc1_h_s_overlap(v->block[v->left_blk_idx][1],
345+ v->block[v->cur_blk_idx][0]);
346+ v->vc1dsp.vc1_h_s_overlap(v->block[v->left_blk_idx][3],
347+ v->block[v->cur_blk_idx][2]);
348+ if(!(s->flags & CODEC_FLAG_GRAY)) {
349+ v->vc1dsp.vc1_h_s_overlap(v->block[v->left_blk_idx][4],
350+ v->block[v->cur_blk_idx][4]);
351+ v->vc1dsp.vc1_h_s_overlap(v->block[v->left_blk_idx][5],
352+ v->block[v->cur_blk_idx][5]);
353+ }
354+ }
355+ v->vc1dsp.vc1_h_s_overlap(v->block[v->cur_blk_idx][0],
356+ v->block[v->cur_blk_idx][1]);
357+ v->vc1dsp.vc1_h_s_overlap(v->block[v->cur_blk_idx][2],
358+ v->block[v->cur_blk_idx][3]);
359+
360+ if (s->mb_x == s->mb_width - 1) {
361+ if(!s->first_slice_line && (v->condover == CONDOVER_ALL || v->pq >= 9 ||
362+ v->over_flags_plane[mb_pos - s->mb_stride])) {
363+ v->vc1dsp.vc1_v_s_overlap(v->block[v->top_blk_idx][2],
364+ v->block[v->cur_blk_idx][0]);
365+ v->vc1dsp.vc1_v_s_overlap(v->block[v->top_blk_idx][3],
366+ v->block[v->cur_blk_idx][1]);
367+ if(!(s->flags & CODEC_FLAG_GRAY)) {
368+ v->vc1dsp.vc1_v_s_overlap(v->block[v->top_blk_idx][4],
369+ v->block[v->cur_blk_idx][4]);
370+ v->vc1dsp.vc1_v_s_overlap(v->block[v->top_blk_idx][5],
371+ v->block[v->cur_blk_idx][5]);
372+ }
373+ }
374+ v->vc1dsp.vc1_v_s_overlap(v->block[v->cur_blk_idx][0],
375+ v->block[v->cur_blk_idx][2]);
376+ v->vc1dsp.vc1_v_s_overlap(v->block[v->cur_blk_idx][1],
377+ v->block[v->cur_blk_idx][3]);
378+ }
379+ }
380+ if (s->mb_x && (v->condover == CONDOVER_ALL || v->over_flags_plane[mb_pos - 1])) {
381+ if(!s->first_slice_line && (v->condover == CONDOVER_ALL || v->pq >= 9 ||
382+ v->over_flags_plane[mb_pos - s->mb_stride - 1])) {
383+ v->vc1dsp.vc1_v_s_overlap(v->block[v->topleft_blk_idx][2],
384+ v->block[v->left_blk_idx][0]);
385+ v->vc1dsp.vc1_v_s_overlap(v->block[v->topleft_blk_idx][3],
386+ v->block[v->left_blk_idx][1]);
387+ if(!(s->flags & CODEC_FLAG_GRAY)) {
388+ v->vc1dsp.vc1_v_s_overlap(v->block[v->topleft_blk_idx][4],
389+ v->block[v->left_blk_idx][4]);
390+ v->vc1dsp.vc1_v_s_overlap(v->block[v->topleft_blk_idx][5],
391+ v->block[v->left_blk_idx][5]);
392+ }
393+ }
394+ v->vc1dsp.vc1_v_s_overlap(v->block[v->left_blk_idx][0],
395+ v->block[v->left_blk_idx][2]);
396+ v->vc1dsp.vc1_v_s_overlap(v->block[v->left_blk_idx][1],
397+ v->block[v->left_blk_idx][3]);
398+ }
399+}
400+
190401 /** Do motion compensation over 1 macroblock
191402 * Mostly adapted hpel_motion and qpel_motion from mpegvideo.c
192403 */
@@ -2016,7 +2227,8 @@ static int vc1_decode_p_block(VC1Context *v, DCTELEM block[64], int n, int mquan · 1823 unmodified lines
20162227 if(i==1)
20172228 v->vc1dsp.vc1_inv_trans_8x8_dc(dst, linesize, block);
20182229 else{
2019− v->vc1dsp.vc1_inv_trans_8x8_add(dst, linesize, block);
2230+ v->vc1dsp.vc1_inv_trans_8x8(block);
2231+ s->dsp.add_pixels_clamped(block, dst, linesize);
20202232 }
20212233 }
20222234 break;
@@ -2258,7 +2470,7 @@ static int vc1_decode_p_mb(VC1Context *v) · 235 unmodified lines
22582470 {
22592471 MpegEncContext *s = &v->s;
22602472 GetBitContext *gb = &s->gb;
2261− int i;
2473+ int i, j;
22622474 int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
22632475 int cbp; /* cbp decoding stuff */
22642476 int mqdiff, mquant; /* MB quantization */
@@ -2288,8 +2500,6 @@ static int vc1_decode_p_mb(VC1Context *v) · 23 unmodified lines
22882500 {
22892501 if (!skipped)
22902502 {
2291− vc1_idct_func idct8x8_fn;
2292−
22932503 GET_MVDATA(dmv_x, dmv_y);
22942504
22952505 if (s->mb_intra) {
@@ -2324,7 +2534,6 @@ static int vc1_decode_p_mb(VC1Context *v) · 28 unmodified lines
23242534 VC1_TTMB_VLC_BITS, 2);
23252535 if(!s->mb_intra) vc1_mc_1mv(v, 0);
23262536 dst_idx = 0;
2327− idct8x8_fn = v->vc1dsp.vc1_inv_trans_8x8_put_signed[!!v->rangeredfrm];
23282537 for (i=0; i<6; i++)
23292538 {
23302539 s->dc_val[0][s->block_index[i]] = 0;
@@ -2342,9 +2551,9 @@ static int vc1_decode_p_mb(VC1Context *v) · 11 unmodified lines
23422551
23432552 vc1_decode_intra_block(v, s->block[i], i, val, mquant, (i&4)?v->codingset2:v->codingset);
23442553 if((i>3) && (s->flags & CODEC_FLAG_GRAY)) continue;
2345− idct8x8_fn(s->dest[dst_idx] + off,
2346− i & 4 ? s->uvlinesize : s->linesize,
2347− s->block[i]);
2554+ v->vc1dsp.vc1_inv_trans_8x8(s->block[i]);
2555+ if(v->rangeredfrm) for(j = 0; j < 64; j++) s->block[i][j] <<= 1;
2556+ s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize);
23482557 if(v->pq >= 9 && v->overlap) {
23492558 if(v->c_avail)
23502559 v->vc1dsp.vc1_h_overlap(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize);
@@ -2380,7 +2589,6 @@ static int vc1_decode_p_mb(VC1Context *v) · 29 unmodified lines
23802589 {
23812590 int intra_count = 0, coded_inter = 0;
23822591 int is_intra[6], is_coded[6];
2383− vc1_idct_func idct8x8_fn;
23842592 /* Get CBPCY */
23852593 cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
23862594 for (i=0; i<6; i++)
@@ -2431,7 +2639,6 @@ static int vc1_decode_p_mb(VC1Context *v) · 44 unmodified lines
24312639 }
24322640 if (!v->ttmbf && coded_inter)
24332641 ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2);
2434− idct8x8_fn = v->vc1dsp.vc1_inv_trans_8x8_put_signed[!!v->rangeredfrm];
24352642 for (i=0; i<6; i++)
24362643 {
24372644 dst_idx += i >> 2;
@@ -2447,9 +2654,9 @@ static int vc1_decode_p_mb(VC1Context *v) · 9 unmodified lines
24472654
24482655 vc1_decode_intra_block(v, s->block[i], i, is_coded[i], mquant, (i&4)?v->codingset2:v->codingset);
24492656 if((i>3) && (s->flags & CODEC_FLAG_GRAY)) continue;
2450− idct8x8_fn(s->dest[dst_idx] + off,
2451− (i&4)?s->uvlinesize:s->linesize,
2452− s->block[i]);
2657+ v->vc1dsp.vc1_inv_trans_8x8(s->block[i]);
2658+ if(v->rangeredfrm) for(j = 0; j < 64; j++) s->block[i][j] <<= 1;
2659+ s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize);
24532660 if(v->pq >= 9 && v->overlap) {
24542661 if(v->c_avail)
24552662 v->vc1dsp.vc1_h_overlap(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize);
@@ -2497,7 +2704,7 @@ static void vc1_decode_b_mb(VC1Context *v) · 41 unmodified lines
24972704 {
24982705 MpegEncContext *s = &v->s;
24992706 GetBitContext *gb = &s->gb;
2500− int i;
2707+ int i, j;
25012708 int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
25022709 int cbp = 0; /* cbp decoding stuff */
25032710 int mqdiff, mquant; /* MB quantization */
@@ -2510,7 +2717,6 @@ static void vc1_decode_b_mb(VC1Context *v) · 6 unmodified lines
25102717 int skipped, direct;
25112718 int dmv_x[2], dmv_y[2];
25122719 int bmvtype = BMV_TYPE_BACKWARD;
2513− vc1_idct_func idct8x8_fn;
25142720
25152721 mquant = v->pq; /* Loosy initialization */
25162722 s->mb_intra = 0;
@@ -2608,7 +2814,6 @@ static void vc1_decode_b_mb(VC1Context *v) · 91 unmodified lines
26082814 }
26092815 }
26102816 dst_idx = 0;
2611− idct8x8_fn = v->vc1dsp.vc1_inv_trans_8x8_put_signed[!!v->rangeredfrm];
26122817 for (i=0; i<6; i++)
26132818 {
26142819 s->dc_val[0][s->block_index[i]] = 0;
@@ -2626,9 +2831,9 @@ static void vc1_decode_b_mb(VC1Context *v) · 11 unmodified lines
26262831
26272832 vc1_decode_intra_block(v, s->block[i], i, val, mquant, (i&4)?v->codingset2:v->codingset);
26282833 if((i>3) && (s->flags & CODEC_FLAG_GRAY)) continue;
2629− idct8x8_fn(s->dest[dst_idx] + off,
2630− i & 4 ? s->uvlinesize : s->linesize,
2631− s->block[i]);
2834+ v->vc1dsp.vc1_inv_trans_8x8(s->block[i]);
2835+ if(v->rangeredfrm) for(j = 0; j < 64; j++) s->block[i][j] <<= 1;
2836+ s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize);
26322837 } else if(val) {
26332838 vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block, s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize, (i&4) && (s->flags & CODEC_FLAG_GRAY), NULL);
26342839 if(!v->ttmbf && ttmb < 8) ttmb = -1;
@@ -2641,12 +2846,11 @@ static void vc1_decode_b_mb(VC1Context *v) · 6 unmodified lines
26412846 */
26422847 static void vc1_decode_i_blocks(VC1Context *v)
26432848 {
2644− int k;
2849+ int k, j;
26452850 MpegEncContext *s = &v->s;
26462851 int cbp, val;
26472852 uint8_t *coded_val;
26482853 int mb_pos;
2649− vc1_idct_func idct8x8_fn;
26502854
26512855 /* select codingmode used for VLC tables selection */
26522856 switch(v->y_ac_table_index){
@@ -2681,10 +2885,6 @@ static void vc1_decode_i_blocks(VC1Context *v) · 28 unmodified lines
26812885 s->mb_x = s->mb_y = 0;
26822886 s->mb_intra = 1;
26832887 s->first_slice_line = 1;
2684− if(v->pq >= 9 && v->overlap) {
2685− idct8x8_fn = v->vc1dsp.vc1_inv_trans_8x8_put_signed[!!v->rangeredfrm];
2686− } else
2687− idct8x8_fn = v->vc1dsp.vc1_inv_trans_8x8_put[!!v->rangeredfrm];
26882888 for(s->mb_y = 0; s->mb_y < s->mb_height; s->mb_y++) {
26892889 s->mb_x = 0;
26902890 ff_init_block_index(s);
@@ -2721,9 +2921,14 @@ static void vc1_decode_i_blocks(VC1Context *v) · 30 unmodified lines
27212921 vc1_decode_i_block(v, s->block[k], k, val, (k<4)? v->codingset : v->codingset2);
27222922
27232923 if (k > 3 && (s->flags & CODEC_FLAG_GRAY)) continue;
2724− idct8x8_fn(dst[k],
2725− k & 4 ? s->uvlinesize : s->linesize,
2726− s->block[k]);
2924+ v->vc1dsp.vc1_inv_trans_8x8(s->block[k]);
2925+ if(v->pq >= 9 && v->overlap) {
2926+ if (v->rangeredfrm) for(j = 0; j < 64; j++) s->block[k][j] <<= 1;
2927+ s->dsp.put_signed_pixels_clamped(s->block[k], dst[k], k & 4 ? s->uvlinesize : s->linesize);
2928+ } else {
2929+ if (v->rangeredfrm) for(j = 0; j < 64; j++) s->block[k][j] = (s->block[k][j] - 64) << 1;
2930+ s->dsp.put_pixels_clamped(s->block[k], dst[k], k & 4 ? s->uvlinesize : s->linesize);
2931+ }
27272932 }
27282933
27292934 if(v->pq >= 9 && v->overlap) {
@@ -2770,7 +2975,7 @@ static void vc1_decode_i_blocks(VC1Context *v) · 40 unmodified lines
27702975
27712976 /** Decode blocks of I-frame for advanced profile
27722977 */
2773−static void vc1_decode_i_blocks_adv(VC1Context *v, int mby_start, int mby_end)
2978+static void vc1_decode_i_blocks_adv(VC1Context *v)
27742979 {
27752980 int k;
27762981 MpegEncContext *s = &v->s;
@@ -2779,9 +2984,7 @@ static void vc1_decode_i_blocks_adv(VC1Context *v, int mby_start, int mby_end) · 2 unmodified lines
27792984 int mb_pos;
27802985 int mquant = v->pq;
27812986 int mqdiff;
2782− int overlap;
27832987 GetBitContext *gb = &s->gb;
2784− vc1_idct_func idct8x8_fn;
27852988
27862989 /* select codingmode used for VLC tables selection */
27872990 switch(v->y_ac_table_index){
@@ -2812,27 +3015,20 @@ static void vc1_decode_i_blocks_adv(VC1Context *v, int mby_start, int mby_end) · 24 unmodified lines
28123015 s->mb_x = s->mb_y = 0;
28133016 s->mb_intra = 1;
28143017 s->first_slice_line = 1;
2815− s->mb_y = mby_start;
2816− if (mby_start) {
3018+ s->mb_y = s->start_mb_y;
3019+ if (s->start_mb_y) {
28173020 s->mb_x = 0;
28183021 ff_init_block_index(s);
28193022 memset(&s->coded_block[s->block_index[0]-s->b8_stride], 0,
28203023 s->b8_stride * sizeof(*s->coded_block));
28213024 }
2822− idct8x8_fn = v->vc1dsp.vc1_inv_trans_8x8_put_signed[0];
2823− for(; s->mb_y < mby_end; s->mb_y++) {
3025+ for(; s->mb_y < s->end_mb_y; s->mb_y++) {
28243026 s->mb_x = 0;
28253027 ff_init_block_index(s);
28263028 for(;s->mb_x < s->mb_width; s->mb_x++) {
2827− uint8_t *dst[6];
3029+ DCTELEM (*block)[64] = v->block[v->cur_blk_idx];
28283030 ff_update_block_index(s);
2829− dst[0] = s->dest[0];
2830− dst[1] = dst[0] + 8;
2831− dst[2] = s->dest[0] + s->linesize * 8;
2832− dst[3] = dst[2] + 8;
2833− dst[4] = s->dest[1];
2834− dst[5] = s->dest[2];
2835− s->dsp.clear_blocks(s->block[0]);
3031+ s->dsp.clear_blocks(block[0]);
28363032 mb_pos = s->mb_x + s->mb_y * s->mb_stride;
28373033 s->current_picture.mb_type[mb_pos] = MB_TYPE_INTRA;
28383034 s->current_picture.motion_val[1][s->block_index[0]][0] = 0;
@@ -2845,13 +3041,8 @@ static void vc1_decode_i_blocks_adv(VC1Context *v, int mby_start, int mby_end) · 6 unmodified lines
28453041 else
28463042 v->s.ac_pred = v->acpred_plane[mb_pos];
28473043
2848− if(v->condover == CONDOVER_SELECT) {
2849− if(v->overflg_is_raw)
2850− overlap = get_bits1(&v->s.gb);
2851− else
2852− overlap = v->over_flags_plane[mb_pos];
2853− } else
2854− overlap = (v->condover == CONDOVER_ALL);
3044+ if (v->condover == CONDOVER_SELECT && v->overflg_is_raw)
3045+ v->over_flags_plane[mb_pos] = get_bits1(&v->s.gb);
28553046
28563047 GET_MQUANT();
28573048
@@ -2873,40 +3064,18 @@ static void vc1_decode_i_blocks_adv(VC1Context *v, int mby_start, int mby_end) · 15 unmodified lines
28733064 v->a_avail = !s->first_slice_line || (k==2 || k==3);
28743065 v->c_avail = !!s->mb_x || (k==1 || k==3);
28753066
2876− vc1_decode_i_block_adv(v, s->block[k], k, val, (k<4)? v->codingset : v->codingset2, mquant);
3067+ vc1_decode_i_block_adv(v, block[k], k, val, (k<4)? v->codingset : v->codingset2, mquant);
28773068
28783069 if (k > 3 && (s->flags & CODEC_FLAG_GRAY)) continue;
2879− idct8x8_fn(dst[k],
2880− k & 4 ? s->uvlinesize : s->linesize,
2881− s->block[k]);
3070+ v->vc1dsp.vc1_inv_trans_8x8(block[k]);
28823071 }
28833072
2884− if(overlap) {
2885− if(s->mb_x) {
2886− v->vc1dsp.vc1_h_overlap(s->dest[0], s->linesize);
2887− v->vc1dsp.vc1_h_overlap(s->dest[0] + 8 * s->linesize, s->linesize);
2888− if(!(s->flags & CODEC_FLAG_GRAY)) {
2889− v->vc1dsp.vc1_h_overlap(s->dest[1], s->uvlinesize);
2890− v->vc1dsp.vc1_h_overlap(s->dest[2], s->uvlinesize);
2891− }
2892− }
2893− v->vc1dsp.vc1_h_overlap(s->dest[0] + 8, s->linesize);
2894− v->vc1dsp.vc1_h_overlap(s->dest[0] + 8 * s->linesize + 8, s->linesize);
2895− if(!s->first_slice_line) {
2896− v->vc1dsp.vc1_v_overlap(s->dest[0], s->linesize);
2897− v->vc1dsp.vc1_v_overlap(s->dest[0] + 8, s->linesize);
2898− if(!(s->flags & CODEC_FLAG_GRAY)) {
2899− v->vc1dsp.vc1_v_overlap(s->dest[1], s->uvlinesize);
2900− v->vc1dsp.vc1_v_overlap(s->dest[2], s->uvlinesize);
2901− }
2902− }
2903− v->vc1dsp.vc1_v_overlap(s->dest[0] + 8 * s->linesize, s->linesize);
2904− v->vc1dsp.vc1_v_overlap(s->dest[0] + 8 * s->linesize + 8, s->linesize);
2905− }
2906− if(v->s.loop_filter) vc1_loop_filter_iblk(v, v->pq);
3073+ vc1_smooth_overlap_filter_iblk(v);
3074+ vc1_put_signed_blocks_clamped(v);
3075+ if(v->s.loop_filter) vc1_loop_filter_iblk_delayed(v, v->pq);
29073076
29083077 if(get_bits_count(&s->gb) > v->bits) {
2909− ff_er_add_slice(s, 0, mby_start, s->mb_x, s->mb_y, (AC_END|DC_END|MV_END));
3078+ ff_er_add_slice(s, 0, s->start_mb_y, s->mb_x, s->mb_y, (AC_END|DC_END|MV_END));
29103079 av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i\n", get_bits_count(&s->gb), v->bits);
29113080 return;
29123081 }
@@ -2917,12 +3086,21 @@ static void vc1_decode_i_blocks_adv(VC1Context *v, int mby_start, int mby_end) · 4 unmodified lines
29173086 ff_draw_horiz_band(s, (s->mb_y-1) * 16, 16);
29183087 s->first_slice_line = 0;
29193088 }
3089+
3090+ /* raw bottom MB row */
3091+ s->mb_x = 0;
3092+ ff_init_block_index(s);
3093+ for(;s->mb_x < s->mb_width; s->mb_x++) {
3094+ ff_update_block_index(s);
3095+ vc1_put_signed_blocks_clamped(v);
3096+ if(v->s.loop_filter) vc1_loop_filter_iblk_delayed(v, v->pq);
3097+ }
29203098 if (v->s.loop_filter)
29213099 ff_draw_horiz_band(s, (s->mb_height-1)*16, 16);
2922− ff_er_add_slice(s, 0, mby_start, s->mb_width - 1, mby_end - 1, (AC_END|DC_END|MV_END));
3100+ ff_er_add_slice(s, 0, s->start_mb_y, s->mb_width - 1, s->end_mb_y - 1, (AC_END|DC_END|MV_END));
29233101 }
29243102
2925−static void vc1_decode_p_blocks(VC1Context *v, int mby_start, int mby_end)
3103+static void vc1_decode_p_blocks(VC1Context *v)
29263104 {
29273105 MpegEncContext *s = &v->s;
29283106 int apply_loop_filter;
@@ -2955,17 +3133,17 @@ static void vc1_decode_p_blocks(VC1Context *v, int mby_start, int mby_end) · 26 unmodified lines
29553133 apply_loop_filter = s->loop_filter && !(s->avctx->skip_loop_filter >= AVDISCARD_NONKEY);
29563134 s->first_slice_line = 1;
29573135 memset(v->cbp_base, 0, sizeof(v->cbp_base[0])*2*s->mb_stride);
2958− for(s->mb_y = mby_start; s->mb_y < mby_end; s->mb_y++) {
3136+ for(s->mb_y = s->start_mb_y; s->mb_y < s->end_mb_y; s->mb_y++) {
29593137 s->mb_x = 0;
29603138 ff_init_block_index(s);
29613139 for(; s->mb_x < s->mb_width; s->mb_x++) {
29623140 ff_update_block_index(s);
29633141
29643142 vc1_decode_p_mb(v);
2965− if (s->mb_y != mby_start && apply_loop_filter)
3143+ if (s->mb_y != s->start_mb_y && apply_loop_filter)
29663144 vc1_apply_p_loop_filter(v);
29673145 if(get_bits_count(&s->gb) > v->bits || get_bits_count(&s->gb) < 0) {
2968− ff_er_add_slice(s, 0, mby_start, s->mb_x, s->mb_y, (AC_END|DC_END|MV_END));
3146+ ff_er_add_slice(s, 0, s->start_mb_y, s->mb_x, s->mb_y, (AC_END|DC_END|MV_END));
29693147 av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i at %ix%i\n", get_bits_count(&s->gb), v->bits,s->mb_x,s->mb_y);
29703148 return;
29713149 }
@@ -2974,7 +3152,7 @@ static void vc1_decode_p_blocks(VC1Context *v, int mby_start, int mby_end) · 2 unmodified lines
29743152 memmove(v->ttblk_base, v->ttblk, sizeof(v->ttblk_base[0])*s->mb_stride);
29753153 memmove(v->is_intra_base, v->is_intra, sizeof(v->is_intra_base[0])*s->mb_stride);
29763154 memmove(v->luma_mv_base, v->luma_mv, sizeof(v->luma_mv_base[0])*s->mb_stride);
2977− if (s->mb_y != mby_start) ff_draw_horiz_band(s, (s->mb_y-1) * 16, 16);
3155+ if (s->mb_y != s->start_mb_y) ff_draw_horiz_band(s, (s->mb_y-1) * 16, 16);
29783156 s->first_slice_line = 0;
29793157 }
29803158 if (apply_loop_filter) {
@@ -2985,12 +3163,12 @@ static void vc1_decode_p_blocks(VC1Context *v, int mby_start, int mby_end) · 4 unmodified lines
29853163 vc1_apply_p_loop_filter(v);
29863164 }
29873165 }
2988− if (mby_end >= mby_start)
2989− ff_draw_horiz_band(s, (mby_end-1) * 16, 16);
2990− ff_er_add_slice(s, 0, mby_start, s->mb_width - 1, mby_end - 1, (AC_END|DC_END|MV_END));
3166+ if (s->end_mb_y >= s->start_mb_y)
3167+ ff_draw_horiz_band(s, (s->end_mb_y-1) * 16, 16);
3168+ ff_er_add_slice(s, 0, s->start_mb_y, s->mb_width - 1, s->end_mb_y - 1, (AC_END|DC_END|MV_END));
29913169 }
29923170
2993−static void vc1_decode_b_blocks(VC1Context *v, int mby_start, int mby_end)
3171+static void vc1_decode_b_blocks(VC1Context *v)
29943172 {
29953173 MpegEncContext *s = &v->s;
29963174
@@ -3020,7 +3198,7 @@ static void vc1_decode_b_blocks(VC1Context *v, int mby_start, int mby_end) · 23 unmodified lines
30203198 }
30213199
30223200 s->first_slice_line = 1;
3023− for(s->mb_y = mby_start; s->mb_y < mby_end; s->mb_y++) {
3201+ for(s->mb_y = s->start_mb_y; s->mb_y < s->end_mb_y; s->mb_y++) {
30243202 s->mb_x = 0;
30253203 ff_init_block_index(s);
30263204 for(; s->mb_x < s->mb_width; s->mb_x++) {
@@ -3028,7 +3206,7 @@ static void vc1_decode_b_blocks(VC1Context *v, int mby_start, int mby_end) · 1 unmodified line
30283206
30293207 vc1_decode_b_mb(v);
30303208 if(get_bits_count(&s->gb) > v->bits || get_bits_count(&s->gb) < 0) {
3031− ff_er_add_slice(s, 0, mby_start, s->mb_x, s->mb_y, (AC_END|DC_END|MV_END));
3209+ ff_er_add_slice(s, 0, s->start_mb_y, s->mb_x, s->mb_y, (AC_END|DC_END|MV_END));
30323210 av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i at %ix%i\n", get_bits_count(&s->gb), v->bits,s->mb_x,s->mb_y);
30333211 return;
30343212 }
@@ -3042,7 +3220,7 @@ static void vc1_decode_b_blocks(VC1Context *v, int mby_start, int mby_end) · 7 unmodified lines
30423220 }
30433221 if (v->s.loop_filter)
30443222 ff_draw_horiz_band(s, (s->mb_height-1)*16, 16);
3045− ff_er_add_slice(s, 0, mby_start, s->mb_width - 1, mby_end - 1, (AC_END|DC_END|MV_END));
3223+ ff_er_add_slice(s, 0, s->start_mb_y, s->mb_width - 1, s->end_mb_y - 1, (AC_END|DC_END|MV_END));
30463224 }
30473225
30483226 static void vc1_decode_skip_blocks(VC1Context *v)
@@ -3064,17 +3242,21 @@ static void vc1_decode_skip_blocks(VC1Context *v) · 15 unmodified lines
30643242 s->pict_type = AV_PICTURE_TYPE_P;
30653243 }
30663244
3067−static void vc1_decode_blocks(VC1Context *v, int mby_start, int mby_end)
3245+static void vc1_decode_blocks(VC1Context *v)
30683246 {
30693247
30703248 v->s.esc3_level_length = 0;
30713249 if(v->x8_type){
30723250 ff_intrax8_decode_picture(&v->x8, 2*v->pq+v->halfpq, v->pq*(!v->pquantizer) );
30733251 }else{
3252+ v->cur_blk_idx = 0;
3253+ v->left_blk_idx = -1;
3254+ v->topleft_blk_idx = 1;
3255+ v->top_blk_idx = 2;
30743256 switch(v->s.pict_type) {
30753257 case AV_PICTURE_TYPE_I:
30763258 if(v->profile == PROFILE_ADVANCED)
3077− vc1_decode_i_blocks_adv(v, mby_start, mby_end);
3259+ vc1_decode_i_blocks_adv(v);
30783260 else
30793261 vc1_decode_i_blocks(v);
30803262 break;
@@ -3082,16 +3264,16 @@ static void vc1_decode_blocks(VC1Context *v, int mby_start, int mby_end) · 1 unmodified line
30823264 if(v->p_frame_skipped)
30833265 vc1_decode_skip_blocks(v);
30843266 else
3085− vc1_decode_p_blocks(v, mby_start, mby_end);
3267+ vc1_decode_p_blocks(v);
30863268 break;
30873269 case AV_PICTURE_TYPE_B:
30883270 if(v->bi_type){
30893271 if(v->profile == PROFILE_ADVANCED)
3090− vc1_decode_i_blocks_adv(v, mby_start, mby_end);
3272+ vc1_decode_i_blocks_adv(v);
30913273 else
30923274 vc1_decode_i_blocks(v);
30933275 }else
3094− vc1_decode_b_blocks(v, mby_start, mby_end);
3276+ vc1_decode_b_blocks(v);
30953277 break;
30963278 }
30973279 }
@@ -3341,6 +3523,8 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx) · 243 unmodified lines
33413523 v->acpred_plane = av_malloc(s->mb_stride * s->mb_height);
33423524 v->over_flags_plane = av_malloc(s->mb_stride * s->mb_height);
33433525
3526+ v->n_allocated_blks = s->mb_width + 2;
3527+ v->block = av_malloc(sizeof(*v->block) * v->n_allocated_blks);
33443528 v->cbp_base = av_malloc(sizeof(v->cbp_base[0]) * 2 * s->mb_stride);
33453529 v->cbp = v->cbp_base + s->mb_stride;
33463530 v->ttblk_base = av_malloc(sizeof(v->ttblk_base[0]) * 2 * s->mb_stride);
@@ -3556,8 +3740,9 @@ static int vc1_decode_frame(AVCodecContext *avctx, · 209 unmodified lines
35563740 for (i = 0; i <= n_slices; i++) {
35573741 if (i && get_bits1(&s->gb))
35583742 vc1_parse_frame_header_adv(v, &s->gb);
3559− vc1_decode_blocks(v, i == 0 ? 0 : FFMAX(0, slices[i-1].mby_start),
3560− i == n_slices ? s->mb_height : FFMIN(s->mb_height, slices[i].mby_start));
3743+ s->start_mb_y = (i == 0) ? 0 : FFMAX(0, slices[i-1].mby_start);
3744+ s->end_mb_y = (i == n_slices) ? s->mb_height : FFMIN(s->mb_height, slices[i].mby_start);
3745+ vc1_decode_blocks(v);
35613746 if (i != n_slices) s->gb = slices[i].gb;
35623747 }
35633748 //av_log(s->avctx, AV_LOG_INFO, "Consumed %i/%i bits\n", get_bits_count(&s->gb), s->gb.size_in_bits);
@@ -3614,6 +3799,7 @@ static av_cold int vc1_decode_end(AVCodecContext *avctx) · 50 unmodified lines
36143799 av_freep(&v->acpred_plane);
36153800 av_freep(&v->over_flags_plane);
36163801 av_freep(&v->mb_type_base);
3802+ av_freep(&v->block);
36173803 av_freep(&v->cbp_base);
36183804 av_freep(&v->ttblk_base);
36193805 av_freep(&v->is_intra_base); // FIXME use v->mb_type[]
libavcodec/vc1dsp.c+64−44
@@ -78,6 +78,58 @@ static void vc1_h_overlap_c(uint8_t* src, int stride) · 77 unmodified lines
7878 }
7979 }
8080
81+static void vc1_v_s_overlap_c(DCTELEM *top, DCTELEM *bottom)
82+{
83+ int i;
84+ int a, b, c, d;
85+ int d1, d2;
86+ int rnd1 = 4, rnd2 = 3;
87+ for(i = 0; i < 8; i++) {
88+ a = top[48];
89+ b = top[56];
90+ c = bottom[0];
91+ d = bottom[8];
92+ d1 = a - d;
93+ d2 = a - d + b - c;
94+
95+ top[48] = ((a << 3) - d1 + rnd1) >> 3;
96+ top[56] = ((b << 3) - d2 + rnd2) >> 3;
97+ bottom[0] = ((c << 3) + d2 + rnd1) >> 3;
98+ bottom[8] = ((d << 3) + d1 + rnd2) >> 3;
99+
100+ bottom++;
101+ top++;
102+ rnd2 = 7 - rnd2;
103+ rnd1 = 7 - rnd1;
104+ }
105+}
106+
107+static void vc1_h_s_overlap_c(DCTELEM *left, DCTELEM *right)
108+{
109+ int i;
110+ int a, b, c, d;
111+ int d1, d2;
112+ int rnd1 = 4, rnd2 = 3;
113+ for(i = 0; i < 8; i++) {
114+ a = left[6];
115+ b = left[7];
116+ c = right[0];
117+ d = right[1];
118+ d1 = a - d;
119+ d2 = a - d + b - c;
120+
121+ left[6] = ((a << 3) - d1 + rnd1) >> 3;
122+ left[7] = ((b << 3) - d2 + rnd2) >> 3;
123+ right[0] = ((c << 3) + d2 + rnd1) >> 3;
124+ right[1] = ((d << 3) + d1 + rnd2) >> 3;
125+
126+ right += 8;
127+ left += 8;
128+ rnd2 = 7 - rnd2;
129+ rnd1 = 7 - rnd1;
130+ }
131+}
132+
81133 /**
82134 * VC-1 in-loop deblocking filter for one line
83135 * @param src source block type
@@ -199,7 +251,7 @@ static void vc1_inv_trans_8x8_dc_c(uint8_t *dest, int linesize, DCTELEM *block) · 115 unmodified lines
199251 }
200252 }
201253
202−static av_always_inline void vc1_inv_trans_8x8_c(DCTELEM block[64], int shl, int sub)
254+static void vc1_inv_trans_8x8_c(DCTELEM block[64])
203255 {
204256 int i;
205257 register int t1,t2,t3,t4,t5,t6,t7,t8;
@@ -254,50 +306,20 @@ static av_always_inline void vc1_inv_trans_8x8_c(DCTELEM block[64], int shl, int · 48 unmodified lines
254306 t3 = 9 * src[ 8] - 16 * src[24] + 4 * src[40] + 15 * src[56];
255307 t4 = 4 * src[ 8] - 9 * src[24] + 15 * src[40] - 16 * src[56];
256308
257− dst[ 0] = (((t5 + t1 ) >> 7) - sub) << shl;
258− dst[ 8] = (((t6 + t2 ) >> 7) - sub) << shl;
259− dst[16] = (((t7 + t3 ) >> 7) - sub) << shl;
260− dst[24] = (((t8 + t4 ) >> 7) - sub) << shl;
261− dst[32] = (((t8 - t4 + 1) >> 7) - sub) << shl;
262− dst[40] = (((t7 - t3 + 1) >> 7) - sub) << shl;
263− dst[48] = (((t6 - t2 + 1) >> 7) - sub) << shl;
264− dst[56] = (((t5 - t1 + 1) >> 7) - sub) << shl;
309+ dst[ 0] = (t5 + t1) >> 7;
310+ dst[ 8] = (t6 + t2) >> 7;
311+ dst[16] = (t7 + t3) >> 7;
312+ dst[24] = (t8 + t4) >> 7;
313+ dst[32] = (t8 - t4 + 1) >> 7;
314+ dst[40] = (t7 - t3 + 1) >> 7;
315+ dst[48] = (t6 - t2 + 1) >> 7;
316+ dst[56] = (t5 - t1 + 1) >> 7;
265317
266318 src++;
267319 dst++;
268320 }
269321 }
270322
271−static void vc1_inv_trans_8x8_add_c(uint8_t *dest, int linesize, DCTELEM *block)
272−{
273− vc1_inv_trans_8x8_c(block, 0, 0);
274− ff_add_pixels_clamped_c(block, dest, linesize);
275−}
276−
277−static void vc1_inv_trans_8x8_put_signed_c(uint8_t *dest, int linesize, DCTELEM *block)
278−{
279− vc1_inv_trans_8x8_c(block, 0, 0);
280− ff_put_signed_pixels_clamped_c(block, dest, linesize);
281−}
282−
283−static void vc1_inv_trans_8x8_put_signed_rangered_c(uint8_t *dest, int linesize, DCTELEM *block)
284−{
285− vc1_inv_trans_8x8_c(block, 1, 0);
286− ff_put_signed_pixels_clamped_c(block, dest, linesize);
287−}
288−
289−static void vc1_inv_trans_8x8_put_c(uint8_t *dest, int linesize, DCTELEM *block)
290−{
291− vc1_inv_trans_8x8_c(block, 0, 0);
292− ff_put_pixels_clamped_c(block, dest, linesize);
293−}
294−
295−static void vc1_inv_trans_8x8_put_rangered_c(uint8_t *dest, int linesize, DCTELEM *block)
296−{
297− vc1_inv_trans_8x8_c(block, 1, 64);
298− ff_put_pixels_clamped_c(block, dest, linesize);
299−}
300−
301323 /** Do inverse transform on 8x4 part of block
302324 */
303325 static void vc1_inv_trans_8x4_dc_c(uint8_t *dest, int linesize, DCTELEM *block)
@@ -692,11 +714,7 @@ static void avg_no_rnd_vc1_chroma_mc8_c(uint8_t *dst/*align 8*/, uint8_t *src/*a · 388 unmodified lines
692714 }
693715
694716 av_cold void ff_vc1dsp_init(VC1DSPContext* dsp) {
695− dsp->vc1_inv_trans_8x8_add = vc1_inv_trans_8x8_add_c;
696− dsp->vc1_inv_trans_8x8_put_signed[0] = vc1_inv_trans_8x8_put_signed_c;
697− dsp->vc1_inv_trans_8x8_put_signed[1] = vc1_inv_trans_8x8_put_signed_rangered_c;
698− dsp->vc1_inv_trans_8x8_put[0] = vc1_inv_trans_8x8_put_c;
699− dsp->vc1_inv_trans_8x8_put[1] = vc1_inv_trans_8x8_put_rangered_c;
717+ dsp->vc1_inv_trans_8x8 = vc1_inv_trans_8x8_c;
700718 dsp->vc1_inv_trans_4x8 = vc1_inv_trans_4x8_c;
701719 dsp->vc1_inv_trans_8x4 = vc1_inv_trans_8x4_c;
702720 dsp->vc1_inv_trans_4x4 = vc1_inv_trans_4x4_c;
@@ -706,6 +724,8 @@ av_cold void ff_vc1dsp_init(VC1DSPContext* dsp) { · 3 unmodified lines
706724 dsp->vc1_inv_trans_4x4_dc = vc1_inv_trans_4x4_dc_c;
707725 dsp->vc1_h_overlap = vc1_h_overlap_c;
708726 dsp->vc1_v_overlap = vc1_v_overlap_c;
727+ dsp->vc1_h_s_overlap = vc1_h_s_overlap_c;
728+ dsp->vc1_v_s_overlap = vc1_v_s_overlap_c;
709729 dsp->vc1_v_loop_filter4 = vc1_v_loop_filter4_c;
710730 dsp->vc1_h_loop_filter4 = vc1_h_loop_filter4_c;
711731 dsp->vc1_v_loop_filter8 = vc1_v_loop_filter8_c;
libavcodec/vc1dsp.h+5−7
@@ -30,13 +30,9 @@ · 29 unmodified lines
3030
3131 #include "dsputil.h"
3232
33−typedef void (*vc1_idct_func)(uint8_t *dest, int line_size, DCTELEM *block);
34−
3533 typedef struct VC1DSPContext {
3634 /* vc1 functions */
37− vc1_idct_func vc1_inv_trans_8x8_add;
38− vc1_idct_func vc1_inv_trans_8x8_put_signed[2];
39− vc1_idct_func vc1_inv_trans_8x8_put[2];
35+ void (*vc1_inv_trans_8x8)(DCTELEM *b);
4036 void (*vc1_inv_trans_8x4)(uint8_t *dest, int line_size, DCTELEM *block);
4137 void (*vc1_inv_trans_4x8)(uint8_t *dest, int line_size, DCTELEM *block);
4238 void (*vc1_inv_trans_4x4)(uint8_t *dest, int line_size, DCTELEM *block);
@@ -44,8 +40,10 @@ typedef struct VC1DSPContext { · 1 unmodified line
4440 void (*vc1_inv_trans_8x4_dc)(uint8_t *dest, int line_size, DCTELEM *block);
4541 void (*vc1_inv_trans_4x8_dc)(uint8_t *dest, int line_size, DCTELEM *block);
4642 void (*vc1_inv_trans_4x4_dc)(uint8_t *dest, int line_size, DCTELEM *block);
47− void (*vc1_v_overlap)(uint8_t* src, int stride);
48− void (*vc1_h_overlap)(uint8_t* src, int stride);
43+ void (*vc1_v_overlap)(uint8_t *src, int stride);
44+ void (*vc1_h_overlap)(uint8_t *src, int stride);
45+ void (*vc1_v_s_overlap)(DCTELEM *top, DCTELEM *bottom);
46+ void (*vc1_h_s_overlap)(DCTELEM *left, DCTELEM *right);
4947 void (*vc1_v_loop_filter4)(uint8_t *src, int stride, int pq);
5048 void (*vc1_h_loop_filter4)(uint8_t *src, int stride, int pq);
5149 void (*vc1_v_loop_filter8)(uint8_t *src, int stride, int pq);
libavfilter/avfilter.c+26−1
@@ -585,28 +585,53 @@ int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *in · 584 unmodified lines
585585 return AVERROR(EINVAL);
586586
587587 ret = av_mallocz(sizeof(AVFilterContext));
588+ if (!ret)
589+ return AVERROR(ENOMEM);
588590
589591 ret->av_class = &avfilter_class;
590592 ret->filter = filter;
591593 ret->name = inst_name ? av_strdup(inst_name) : NULL;
592− ret->priv = av_mallocz(filter->priv_size);
594+ if (filter->priv_size) {
595+ ret->priv = av_mallocz(filter->priv_size);
596+ if (!ret->priv)
597+ goto err;
598+ }
593599
594600 ret->input_count = pad_count(filter->inputs);
595601 if (ret->input_count) {
596602 ret->input_pads = av_malloc(sizeof(AVFilterPad) * ret->input_count);
603+ if (!ret->input_pads)
604+ goto err;
597605 memcpy(ret->input_pads, filter->inputs, sizeof(AVFilterPad) * ret->input_count);
598606 ret->inputs = av_mallocz(sizeof(AVFilterLink*) * ret->input_count);
607+ if (!ret->inputs)
608+ goto err;
599609 }
600610
601611 ret->output_count = pad_count(filter->outputs);
602612 if (ret->output_count) {
603613 ret->output_pads = av_malloc(sizeof(AVFilterPad) * ret->output_count);
614+ if (!ret->output_pads)
615+ goto err;
604616 memcpy(ret->output_pads, filter->outputs, sizeof(AVFilterPad) * ret->output_count);
605617 ret->outputs = av_mallocz(sizeof(AVFilterLink*) * ret->output_count);
618+ if (!ret->outputs)
619+ goto err;
606620 }
607621
608622 *filter_ctx = ret;
609623 return 0;
624+
625+err:
626+ av_freep(&ret->inputs);
627+ av_freep(&ret->input_pads);
628+ ret->input_count = 0;
629+ av_freep(&ret->outputs);
630+ av_freep(&ret->output_pads);
631+ ret->output_count = 0;
632+ av_freep(&ret->priv);
633+ av_free(ret);
634+ return AVERROR(ENOMEM);
610635 }
611636
612637 void avfilter_free(AVFilterContext *filter)
libavformat/Makefile+2−1
@@ -299,7 +299,8 @@ OBJS-$(CONFIG_WEBM_MUXER) += matroskaenc.o matroska.o \ · 298 unmodified lines
299299 flacenc_header.o avlanguage.o
300300 OBJS-$(CONFIG_WSAUD_DEMUXER) += westwood.o
301301 OBJS-$(CONFIG_WSVQA_DEMUXER) += westwood.o
302−OBJS-$(CONFIG_WTV_DEMUXER) += wtvdec.o wtv.o asf.o asfdec.o mpegts.o riff.o
302+OBJS-$(CONFIG_WTV_DEMUXER) += wtvdec.o wtv.o asfdec.o asf.o asfcrypt.o \
303+ avlanguage.o mpegts.o isom.o riff.o
303304 OBJS-$(CONFIG_WV_DEMUXER) += wv.o apetag.o
304305 OBJS-$(CONFIG_XA_DEMUXER) += xa.o
305306 OBJS-$(CONFIG_XWMA_DEMUXER) += xwma.o riff.o
libavformat/asfdec.c+12−2
@@ -845,11 +845,21 @@ static int asf_read_frame_header(AVFormatContext *s, AVIOContext *pb){ · 844 unmodified lines
845845 if (asf->packet_flags & 0x01) {
846846 DO_2BITS(asf->packet_segsizetype >> 6, asf->packet_frag_size, 0); // 0 is illegal
847847 if(asf->packet_frag_size > asf->packet_size_left - rsize){
848− av_log(s, AV_LOG_ERROR, "packet_frag_size is invalid\n");
849− return -1;
848+ if (asf->packet_frag_size > asf->packet_size_left - rsize + asf->packet_padsize) {
849+ av_log(s, AV_LOG_ERROR, "packet_frag_size is invalid (%d-%d)\n", asf->packet_size_left, rsize);
850+ return -1;
851+ } else {
852+ int diff = asf->packet_frag_size - (asf->packet_size_left - rsize);
853+ asf->packet_size_left += diff;
854+ asf->packet_padsize -= diff;
855+ }
850856 }
851857 //printf("Fragsize %d\n", asf->packet_frag_size);
852858 } else {
859+ if (rsize > asf->packet_size_left) {
860+ av_log(s, AV_LOG_ERROR, "packet_replic_size is invalid\n");
861+ return -1;
862+ }
853863 asf->packet_frag_size = asf->packet_size_left - rsize;
854864 //printf("Using rest %d %d %d\n", asf->packet_frag_size, asf->packet_size_left, rsize);
855865 }
libavformat/file.c+13−13
@@ -51,6 +51,19 @@ static int file_get_handle(URLContext *h) · 50 unmodified lines
5151 return (intptr_t) h->priv_data;
5252 }
5353
54+static int file_check(URLContext *h, int mask)
55+{
56+ struct stat st;
57+ int ret = stat(h->filename, &st);
58+ if (ret < 0)
59+ return AVERROR(errno);
60+
61+ ret |= st.st_mode&S_IRUSR ? mask&AVIO_FLAG_READ : 0;
62+ ret |= st.st_mode&S_IWUSR ? mask&AVIO_FLAG_WRITE : 0;
63+
64+ return ret;
65+}
66+
5467 #if CONFIG_FILE_PROTOCOL
5568
5669 static int file_open(URLContext *h, const char *filename, int flags)
@@ -95,19 +108,6 @@ static int file_close(URLContext *h) · 38 unmodified lines
95108 return close(fd);
96109 }
97110
98−static int file_check(URLContext *h, int mask)
99−{
100− struct stat st;
101− int ret = stat(h->filename, &st);
102− if (ret < 0)
103− return AVERROR(errno);
104−
105− ret |= st.st_mode&S_IRUSR ? mask&AVIO_FLAG_READ : 0;
106− ret |= st.st_mode&S_IWUSR ? mask&AVIO_FLAG_WRITE : 0;
107−
108− return ret;
109−}
110−
111111 URLProtocol ff_file_protocol = {
112112 .name = "file",
113113 .url_open = file_open,
libavformat/matroskaenc.c+2−2
@@ -403,8 +403,6 @@ static int64_t mkv_write_cues(AVIOContext *pb, mkv_cues *cues, int num_tracks) · 402 unmodified lines
403403 }
404404 end_ebml_master(pb, cues_element);
405405
406− av_free(cues->entries);
407− av_free(cues);
408406 return currentpos;
409407 }
410408
@@ -1164,6 +1162,8 @@ static int mkv_write_trailer(AVFormatContext *s) · 753 unmodified lines
11641162
11651163 end_ebml_master(pb, mkv->segment);
11661164 av_free(mkv->tracks);
1165+ av_freep(&mkv->cues->entries);
1166+ av_freep(&mkv->cues);
11671167 av_destruct_packet(&mkv->cur_audio_pkt);
11681168 avio_flush(pb);
11691169 return 0;
libavformat/movenc.c+1−1
@@ -829,7 +829,7 @@ static int mov_write_video_tag(AVIOContext *pb, MOVTrack *track) · 828 unmodified lines
829829 memset(compressor_name,0,32);
830830 /* FIXME not sure, ISO 14496-1 draft where it shall be set to 0 */
831831 if (track->mode == MODE_MOV && track->enc->codec && track->enc->codec->name)
832− strncpy(compressor_name,track->enc->codec->name,31);
832+ av_strlcpy(compressor_name,track->enc->codec->name,32);
833833 avio_w8(pb, strlen(compressor_name));
834834 avio_write(pb, compressor_name, 31);
835835
libavformat/mp3enc.c+2−1
@@ -24,6 +24,7 @@ · 23 unmodified lines
2424 #include "id3v1.h"
2525 #include "id3v2.h"
2626 #include "rawenc.h"
27+#include "libavutil/avstring.h"
2728 #include "libavutil/intreadwrite.h"
2829 #include "libavutil/opt.h"
2930
@@ -32,7 +33,7 @@ static int id3v1_set_string(AVFormatContext *s, const char *key, · 2 unmodified lines
3233 {
3334 AVMetadataTag *tag;
3435 if ((tag = av_metadata_get(s->metadata, key, NULL, 0)))
35− strncpy(buf, tag->value, buf_size);
36+ av_strlcpy(buf, tag->value, buf_size);
3637 return !!tag;
3738 }
3839
libavformat/nutenc.c+6−0
@@ -589,6 +589,12 @@ static int write_header(AVFormatContext *s){ · 588 unmodified lines
589589 nut->chapter = av_mallocz(sizeof(ChapterContext)*s->nb_chapters);
590590 nut->time_base= av_mallocz(sizeof(AVRational )*(s->nb_streams +
591591 s->nb_chapters));
592+ if (!nut->stream || (s->nb_chapters && !nut->chapter) || !nut->time_base) {
593+ av_freep(&nut->stream);
594+ av_freep(&nut->chapter);
595+ av_freep(&nut->time_base);
596+ return AVERROR(ENOMEM);
597+ }
592598
593599 for(i=0; i<s->nb_streams; i++){
594600 AVStream *st= s->streams[i];
libpostproc/postprocess.c+2−1
@@ -86,6 +86,7 @@ try to unroll inner for(x=0 ... loop to avoid these damn if(x ... checks · 85 unmodified lines
8686 //#define DEBUG_BRIGHTNESS
8787 #include "postprocess.h"
8888 #include "postprocess_internal.h"
89+#include "libavutil/avstring.h"
8990
9091 unsigned postproc_version(void)
9192 {
@@ -766,7 +767,7 @@ pp_mode *pp_get_mode_by_name_and_quality(const char *name, int quality) · 674 unmodified lines
766767 ppMode->maxClippedThreshold= 0.01;
767768 ppMode->error=0;
768769
769− strncpy(temp, name, GET_MODE_BUFFER_SIZE);
770+ av_strlcpy(temp, name, GET_MODE_BUFFER_SIZE);
770771
771772 av_log(NULL, AV_LOG_DEBUG, "pp: %s\n", name);
772773
tests/ref/fate/vc1+15−15
@@ -1,15 +1,15 @@
1−0, 0, 38016, 0xf4715db5
2−0, 3600, 38016, 0xf4715db5
3−0, 7200, 38016, 0xf4715db5
4−0, 10800, 38016, 0xf46af0e1
5−0, 14400, 38016, 0x9c1c2cf1
6−0, 18000, 38016, 0xff12d87f
7−0, 21600, 38016, 0x7408432b
8−0, 25200, 38016, 0x7408432b
9−0, 28800, 38016, 0x8d11479a
10−0, 32400, 38016, 0x8d11479a
11−0, 36000, 38016, 0xc4a121ab
12−0, 39600, 38016, 0xc4a121ab
13−0, 43200, 38016, 0xc4a121ab
14−0, 46800, 38016, 0xc4a121ab
15−0, 50400, 38016, 0xc4a121ab
1+0, 0, 38016, 0xa6f15db5
2+0, 3600, 38016, 0xa6f15db5
3+0, 7200, 38016, 0xa6f15db5
4+0, 10800, 38016, 0x5c4ef0e7
5+0, 14400, 38016, 0x53a42d1d
6+0, 18000, 38016, 0x68f7d89e
7+0, 21600, 38016, 0xc15f4368
8+0, 25200, 38016, 0xc15f4368
9+0, 28800, 38016, 0xd1bd47a8
10+0, 32400, 38016, 0xd1bd47a8
11+0, 36000, 38016, 0xe1e821ca
12+0, 39600, 38016, 0xe1e821ca
13+0, 43200, 38016, 0xe1e821ca
14+0, 46800, 38016, 0xe1e821ca
15+0, 50400, 38016, 0xe1e821ca

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t