From 154ff81870ce9838eaa87b19d0f5ecceb9dd514e Mon Sep 17 00:00:00 2001 From: Janne Grunau Date: Wed, 10 Oct 2012 14:25:44 +0200 Subject: [PATCH 01/10] h263: avoid memcpys over array bound in motion vector caching for obmc Fixes CID602232. --- libavcodec/mpegvideo_motion.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/libavcodec/mpegvideo_motion.c b/libavcodec/mpegvideo_motion.c index 22948e2a2f..9168793183 100644 --- a/libavcodec/mpegvideo_motion.c +++ b/libavcodec/mpegvideo_motion.c @@ -638,37 +638,45 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s, prefetch_motion(s, ref_picture, dir); if(!is_mpeg12 && s->obmc && s->pict_type != AV_PICTURE_TYPE_B){ - int16_t mv_cache[4][4][2]; + LOCAL_ALIGNED_8(int16_t, mv_cache, [4], [4][2]); + AVFrame *cur_frame = &s->current_picture.f; const int xy= s->mb_x + s->mb_y*s->mb_stride; const int mot_stride= s->b8_stride; const int mot_xy= mb_x*2 + mb_y*2*mot_stride; assert(!s->mb_skipped); - memcpy(mv_cache[1][1], s->current_picture.f.motion_val[0][mot_xy ], sizeof(int16_t) * 4); - memcpy(mv_cache[2][1], s->current_picture.f.motion_val[0][mot_xy + mot_stride], sizeof(int16_t) * 4); - memcpy(mv_cache[3][1], s->current_picture.f.motion_val[0][mot_xy + mot_stride], sizeof(int16_t) * 4); + AV_COPY32(mv_cache[1][1], cur_frame->motion_val[0][mot_xy ]); + AV_COPY32(mv_cache[1][2], cur_frame->motion_val[0][mot_xy + 1]); - if (mb_y == 0 || IS_INTRA(s->current_picture.f.mb_type[xy - s->mb_stride])) { - memcpy(mv_cache[0][1], mv_cache[1][1], sizeof(int16_t)*4); + AV_COPY32(mv_cache[2][1], cur_frame->motion_val[0][mot_xy + mot_stride ]); + AV_COPY32(mv_cache[2][2], cur_frame->motion_val[0][mot_xy + mot_stride + 1]); + + AV_COPY32(mv_cache[3][1], cur_frame->motion_val[0][mot_xy + mot_stride ]); + AV_COPY32(mv_cache[3][2], cur_frame->motion_val[0][mot_xy + mot_stride + 1]); + + if (mb_y == 0 || IS_INTRA(cur_frame->mb_type[xy - s->mb_stride])) { + AV_COPY32(mv_cache[0][1], mv_cache[1][1]); + AV_COPY32(mv_cache[0][2], mv_cache[1][2]); }else{ - memcpy(mv_cache[0][1], s->current_picture.f.motion_val[0][mot_xy - mot_stride], sizeof(int16_t) * 4); + AV_COPY32(mv_cache[0][1], cur_frame->motion_val[0][mot_xy - mot_stride ]); + AV_COPY32(mv_cache[0][2], cur_frame->motion_val[0][mot_xy - mot_stride + 1]); } - if (mb_x == 0 || IS_INTRA(s->current_picture.f.mb_type[xy - 1])) { + if (mb_x == 0 || IS_INTRA(cur_frame->mb_type[xy - 1])) { AV_COPY32(mv_cache[1][0], mv_cache[1][1]); AV_COPY32(mv_cache[2][0], mv_cache[2][1]); }else{ - AV_COPY32(mv_cache[1][0], s->current_picture.f.motion_val[0][mot_xy - 1]); - AV_COPY32(mv_cache[2][0], s->current_picture.f.motion_val[0][mot_xy - 1 + mot_stride]); + AV_COPY32(mv_cache[1][0], cur_frame->motion_val[0][mot_xy - 1]); + AV_COPY32(mv_cache[2][0], cur_frame->motion_val[0][mot_xy - 1 + mot_stride]); } - if (mb_x + 1 >= s->mb_width || IS_INTRA(s->current_picture.f.mb_type[xy + 1])) { + if (mb_x + 1 >= s->mb_width || IS_INTRA(cur_frame->mb_type[xy + 1])) { AV_COPY32(mv_cache[1][3], mv_cache[1][2]); AV_COPY32(mv_cache[2][3], mv_cache[2][2]); }else{ - AV_COPY32(mv_cache[1][3], s->current_picture.f.motion_val[0][mot_xy + 2]); - AV_COPY32(mv_cache[2][3], s->current_picture.f.motion_val[0][mot_xy + 2 + mot_stride]); + AV_COPY32(mv_cache[1][3], cur_frame->motion_val[0][mot_xy + 2]); + AV_COPY32(mv_cache[2][3], cur_frame->motion_val[0][mot_xy + 2 + mot_stride]); } mx = 0; From 74e742d6ad09becc2d43e5382c141e0356ad6071 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Tue, 23 Oct 2012 21:12:48 +0200 Subject: [PATCH 02/10] doxygen: Drop some pointless entries from PREDEFINED macros list --- doc/Doxyfile | 6 ------ 1 file changed, 6 deletions(-) diff --git a/doc/Doxyfile b/doc/Doxyfile index 1b4e7d528b..eb394f0a6e 100644 --- a/doc/Doxyfile +++ b/doc/Doxyfile @@ -1374,12 +1374,6 @@ INCLUDE_FILE_PATTERNS = # instead of the = operator. PREDEFINED = "__attribute__(x)=" \ - "RENAME(x)=x ## _TMPL" \ - "DEF(x)=x ## _TMPL" \ - HAVE_AV_CONFIG_H \ - HAVE_MMX \ - HAVE_MMXEXT \ - HAVE_AMD3DNOW \ "DECLARE_ALIGNED(a,t,n)=t n" \ "offsetof(x,y)=0x42" From 13bbefd57e8dcabae650f4a02e667d5c003c289f Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Mon, 22 Oct 2012 16:16:07 +0200 Subject: [PATCH 03/10] doxygen: Add av_alloc_size to list of predefined macros This avoids Doxygen believing the attribute is the function name. --- doc/Doxyfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/Doxyfile b/doc/Doxyfile index eb394f0a6e..aa1f4e2947 100644 --- a/doc/Doxyfile +++ b/doc/Doxyfile @@ -1375,7 +1375,8 @@ INCLUDE_FILE_PATTERNS = PREDEFINED = "__attribute__(x)=" \ "DECLARE_ALIGNED(a,t,n)=t n" \ - "offsetof(x,y)=0x42" + "offsetof(x,y)=0x42" \ + av_alloc_size \ # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. From 20015379a46a3b261f57b0daf0c7237b62c1fd82 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Wed, 24 Oct 2012 01:05:04 +0200 Subject: [PATCH 04/10] cook: cosmetics: Better name for ccpl COOKSubpacket member --- libavcodec/cook.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libavcodec/cook.c b/libavcodec/cook.c index c5b17f98da..28ee8ed149 100644 --- a/libavcodec/cook.c +++ b/libavcodec/cook.c @@ -79,7 +79,7 @@ typedef struct { int samples_per_channel; int log2_numvector_size; unsigned int channel_mask; - VLC ccpl; ///< channel coupling + VLC channel_coupling; int joint_stereo; int bits_per_subpacket; int bits_per_subpdiv; @@ -205,7 +205,8 @@ static av_cold int init_cook_vlc_tables(COOKContext *q) for (i = 0; i < q->num_subpackets; i++) { if (q->subpacket[i].joint_stereo == 1) { - result |= init_vlc(&q->subpacket[i].ccpl, 6, (1 << q->subpacket[i].js_vlc_bits) - 1, + result |= init_vlc(&q->subpacket[i].channel_coupling, 6, + (1 << q->subpacket[i].js_vlc_bits) - 1, ccpl_huffbits[q->subpacket[i].js_vlc_bits - 2], 1, 1, ccpl_huffcodes[q->subpacket[i].js_vlc_bits - 2], 2, 2, 0); av_log(q->avctx, AV_LOG_DEBUG, "subpacket %i Joint-stereo VLC used.\n", i); @@ -326,7 +327,7 @@ static av_cold int cook_decode_close(AVCodecContext *avctx) for (i = 0; i < 7; i++) ff_free_vlc(&q->sqvh[i]); for (i = 0; i < q->num_subpackets; i++) - ff_free_vlc(&q->subpacket[i].ccpl); + ff_free_vlc(&q->subpacket[i].channel_coupling); av_log(avctx, AV_LOG_DEBUG, "Memory deallocated.\n"); @@ -767,7 +768,9 @@ static void decouple_info(COOKContext *q, COOKSubpacket *p, int *decouple_tab) if (vlc) for (i = 0; i < length; i++) - decouple_tab[start + i] = get_vlc2(&q->gb, p->ccpl.table, p->ccpl.bits, 2); + decouple_tab[start + i] = get_vlc2(&q->gb, + p->channel_coupling.table, + p->channel_coupling.bits, 2); else for (i = 0; i < length; i++) decouple_tab[start + i] = get_bits(&q->gb, p->js_vlc_bits); From f23b4a068230fb4ebed2449cd5f303f3b16d333d Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Wed, 24 Oct 2012 01:08:19 +0200 Subject: [PATCH 05/10] cook: cosmetics: Better names for joint_decode() function parameters --- libavcodec/cook.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/libavcodec/cook.c b/libavcodec/cook.c index 28ee8ed149..05efa50f1d 100644 --- a/libavcodec/cook.c +++ b/libavcodec/cook.c @@ -809,8 +809,8 @@ static void decouple_float(COOKContext *q, * @param mlt_buffer1 pointer to left channel mlt coefficients * @param mlt_buffer2 pointer to right channel mlt coefficients */ -static int joint_decode(COOKContext *q, COOKSubpacket *p, float *mlt_buffer1, - float *mlt_buffer2) +static int joint_decode(COOKContext *q, COOKSubpacket *p, + float *mlt_buffer_left, float *mlt_buffer_right) { int i, j, res; int decouple_tab[SUBBAND_SIZE] = { 0 }; @@ -822,8 +822,8 @@ static int joint_decode(COOKContext *q, COOKSubpacket *p, float *mlt_buffer1, memset(decode_buffer, 0, sizeof(q->decode_buffer_0)); /* Make sure the buffers are zeroed out. */ - memset(mlt_buffer1, 0, 1024 * sizeof(*mlt_buffer1)); - memset(mlt_buffer2, 0, 1024 * sizeof(*mlt_buffer2)); + memset(mlt_buffer_left, 0, 1024 * sizeof(*mlt_buffer_left)); + memset(mlt_buffer_right, 0, 1024 * sizeof(*mlt_buffer_right)); decouple_info(q, p, decouple_tab); if ((res = mono_decode(q, p, decode_buffer)) < 0) return res; @@ -831,8 +831,8 @@ static int joint_decode(COOKContext *q, COOKSubpacket *p, float *mlt_buffer1, /* The two channels are stored interleaved in decode_buffer. */ for (i = 0; i < p->js_subband_start; i++) { for (j = 0; j < SUBBAND_SIZE; j++) { - mlt_buffer1[i * 20 + j] = decode_buffer[i * 40 + j]; - mlt_buffer2[i * 20 + j] = decode_buffer[i * 40 + 20 + j]; + mlt_buffer_left[i * 20 + j] = decode_buffer[i * 40 + j]; + mlt_buffer_right[i * 20 + j] = decode_buffer[i * 40 + 20 + j]; } } @@ -845,7 +845,8 @@ static int joint_decode(COOKContext *q, COOKSubpacket *p, float *mlt_buffer1, cplscale = q->cplscales[p->js_vlc_bits - 2]; // choose decoupler table f1 = cplscale[decouple_tab[cpl_tmp] + 1]; f2 = cplscale[idx]; - q->decouple(q, p, i, f1, f2, decode_buffer, mlt_buffer1, mlt_buffer2); + q->decouple(q, p, i, f1, f2, decode_buffer, + mlt_buffer_left, mlt_buffer_right); idx = (1 << p->js_vlc_bits) - 1; } From 8a61ba0e8194beffdfd9f843bdcf29dbbc974ca5 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Wed, 24 Oct 2012 16:03:31 +0200 Subject: [PATCH 06/10] cook: Remove senseless maybe_reformat_buffer32() function --- libavcodec/cook.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/libavcodec/cook.c b/libavcodec/cook.c index 05efa50f1d..713d0b1e7e 100644 --- a/libavcodec/cook.c +++ b/libavcodec/cook.c @@ -241,17 +241,11 @@ static av_cold int init_cook_mlt(COOKContext *q) return 0; } -static const float *maybe_reformat_buffer32(COOKContext *q, const float *ptr, int n) -{ - if (1) - return ptr; -} - static av_cold void init_cplscales_table(COOKContext *q) { int i; for (i = 0; i < 5; i++) - q->cplscales[i] = maybe_reformat_buffer32(q, cplscales[i], (1 << (i + 2)) - 1); + q->cplscales[i] = cplscales[i]; } /*************** init functions end ***********/ From 707f58f515eeb282563af3c443cac10c2d3e81b4 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Wed, 24 Oct 2012 19:00:33 +0200 Subject: [PATCH 07/10] cook: Remove some silly Doxygen comments --- libavcodec/cook.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/libavcodec/cook.c b/libavcodec/cook.c index 713d0b1e7e..a45bd80280 100644 --- a/libavcodec/cook.c +++ b/libavcodec/cook.c @@ -84,11 +84,11 @@ typedef struct { int bits_per_subpacket; int bits_per_subpdiv; int total_subbands; - int numvector_size; ///< 1 << log2_numvector_size; + int numvector_size; // 1 << log2_numvector_size; float mono_previous_buffer1[1024]; float mono_previous_buffer2[1024]; - /** gain buffers */ + cook_gains gains1; cook_gains gains2; int gain_1[9]; @@ -299,9 +299,6 @@ static inline int decode_bytes(const uint8_t *inbuffer, uint8_t *out, int bytes) return off; } -/** - * Cook uninit - */ static av_cold int cook_decode_close(AVCodecContext *avctx) { int i; @@ -631,12 +628,6 @@ static void decode_vectors(COOKContext *q, COOKSubpacket *p, int *category, } -/** - * function for decoding mono data - * - * @param q pointer to the COOKContext - * @param mlt_buffer pointer to mlt coefficients - */ static int mono_decode(COOKContext *q, COOKSubpacket *p, float *mlt_buffer) { int category_index[128] = { 0 }; @@ -747,7 +738,6 @@ static void imlt_gain(COOKContext *q, float *inbuffer, * * @param q pointer to the COOKContext * @param decouple_tab decoupling array - * */ static void decouple_info(COOKContext *q, COOKSubpacket *p, int *decouple_tab) { @@ -954,11 +944,6 @@ static int decode_subpacket(COOKContext *q, COOKSubpacket *p, } -/** - * Cook frame decoding - * - * @param avctx pointer to the AVCodecContext - */ static int cook_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) { From 87cdd7c6949e0166a22b558e0657ac277c95d452 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Wed, 24 Oct 2012 11:54:03 +0200 Subject: [PATCH 08/10] ivi_common: Drop unused function parameter from decode_band() --- libavcodec/ivi_common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/ivi_common.c b/libavcodec/ivi_common.c index 149fffe34f..85661281ad 100644 --- a/libavcodec/ivi_common.c +++ b/libavcodec/ivi_common.c @@ -644,7 +644,7 @@ void ff_ivi_output_plane(IVIPlaneDesc *plane, uint8_t *dst, int dst_pitch) * @param[in] avctx ptr to the AVCodecContext * @return result code: 0 = OK, -1 = error */ -static int decode_band(IVI45DecContext *ctx, int plane_num, +static int decode_band(IVI45DecContext *ctx, IVIBandDesc *band, AVCodecContext *avctx) { int result, i, t, idx1, idx2, pos; @@ -775,7 +775,7 @@ int ff_ivi_decode_frame(AVCodecContext *avctx, void *data, int *data_size, if (ctx->is_nonnull_frame(ctx)) { for (p = 0; p < 3; p++) { for (b = 0; b < ctx->planes[p].num_bands; b++) { - result = decode_band(ctx, p, &ctx->planes[p].bands[b], avctx); + result = decode_band(ctx, &ctx->planes[p].bands[b], avctx); if (result) { av_log(avctx, AV_LOG_ERROR, "Error while decoding band: %d, plane: %d\n", b, p); From ca7f59119b8a53d60418c4adccb0c46922795f79 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 25 Oct 2012 18:25:25 +0200 Subject: [PATCH 09/10] doc: git-howto: Clarify comment about pushing series of commits --- doc/git-howto.texi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/git-howto.texi b/doc/git-howto.texi index 51141157c1..68e0061d74 100644 --- a/doc/git-howto.texi +++ b/doc/git-howto.texi @@ -416,8 +416,8 @@ a panacea. Do not hesitate to perform any other tests necessary to convince yourself that the changes you are about to push actually work as expected. Also note that every single commit should pass the test suite, not just -the result of a series of patches. So if you have a series of related -commits, run the test suite on every single commit. +the result of a series of patches. So if you have a series of commits +to push, run the test suite on every single commit. Finally, after pushing, mark all patches as committed on @url{http://patches.libav.org/,patchwork}. From 1aa07aa21c4ee39f0ed5fcd33d8259eed74bd3ab Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Fri, 26 Oct 2012 14:42:47 +0100 Subject: [PATCH 10/10] configure: fix tests for 2-arg math functions Signed-off-by: Mans Rullgard --- configure | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/configure b/configure index bfa3a616e5..81f945fe26 100755 --- a/configure +++ b/configure @@ -785,11 +785,13 @@ EOF check_mathfunc(){ log check_mathfunc "$@" func=$1 - shift + narg=$2 + shift 2 + test $narg = 2 && args="f, g" || args="f" disable $func check_ld "$@" < -float foo(float f) { return $func(f); } +float foo(float f, float g) { return $func($args); } int main(void){ return 0; } EOF } @@ -3306,8 +3308,12 @@ done check_lib math.h sin -lm && LIBM="-lm" enabled vaapi && require vaapi va/va.h vaInitialize -lva +atan2f_args=2 +ldexpf_args=2 +powf_args=2 + for func in $MATH_FUNCS; do - check_mathfunc $func + eval check_mathfunc $func \${${func}_args:-1} done # these are off by default, so fail if requested and not available