From 940b06aeb8927ca78239007b7b19f2f160055d0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reimar=20D=C3=B6ffinger?= Date: Wed, 6 Mar 2013 00:25:18 +0100 Subject: [PATCH 1/4] kgv1dec: Simplify kega decoding by using memcpy instead of loops Fixes decoding errors with icc 13.1 Signed-off-by: Carl Eugen Hoyos --- libavcodec/kgv1dec.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/libavcodec/kgv1dec.c b/libavcodec/kgv1dec.c index 008843c673..6687e6bc0c 100644 --- a/libavcodec/kgv1dec.c +++ b/libavcodec/kgv1dec.c @@ -93,8 +93,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, out[outcnt++] = code; // rgb555 pixel coded directly } else { int count; - int inp_off; - uint16_t *inp; if ((code & 0x6000) == 0x6000) { // copy from previous frame @@ -112,7 +110,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, start = (outcnt + offsets[oidx]) % maxcnt; - if (maxcnt - start < count) + if (maxcnt - start < count || maxcnt - outcnt < count) break; if (!prev) { @@ -121,8 +119,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, break; } - inp = prev; - inp_off = start; + memcpy(out + outcnt, prev + start, 2 * count); } else { // copy from earlier in this frame int offset = (code & 0x1FFF) + 1; @@ -137,19 +134,12 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, count = 4 + *buf++; } - if (outcnt < offset) + if (outcnt < offset || maxcnt - outcnt < count) break; - inp = out; - inp_off = outcnt - offset; - } - - if (maxcnt - outcnt < count) - break; - - for (i = inp_off; i < count + inp_off; i++) { - out[outcnt++] = inp[i]; + av_memcpy_backptr((uint8_t *)out + 2 * outcnt, 2 * offset, 2 * count); } + outcnt += count; } } From 96d2e4d61a51e4d0c7cc9e78b95d49c833b0459f Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Wed, 6 Mar 2013 00:35:08 +0100 Subject: [PATCH 2/4] Use uint8_t instead of uint16_t pointer in kega decoder. This change allows to remove a few casts and avoids a potential pointer aliasing violation. --- libavcodec/kgv1dec.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/libavcodec/kgv1dec.c b/libavcodec/kgv1dec.c index 6687e6bc0c..6b81095af9 100644 --- a/libavcodec/kgv1dec.c +++ b/libavcodec/kgv1dec.c @@ -50,7 +50,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, const uint8_t *buf_end = buf + avpkt->size; KgvContext * const c = avctx->priv_data; int offsets[8]; - uint16_t *out, *prev; + uint8_t *out, *prev; int outcnt = 0, maxcnt; int w, h, i, res; @@ -75,9 +75,9 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, c->cur.reference = 3; if ((res = ff_get_buffer(avctx, &c->cur)) < 0) return res; - out = (uint16_t *) c->cur.data[0]; + out = c->cur.data[0]; if (c->prev.data[0]) { - prev = (uint16_t *) c->prev.data[0]; + prev = c->prev.data[0]; } else { prev = NULL; } @@ -90,7 +90,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, buf += 2; if (!(code & 0x8000)) { - out[outcnt++] = code; // rgb555 pixel coded directly + AV_WN16A(&out[2 * outcnt], code); // rgb555 pixel coded directly + outcnt++; } else { int count; @@ -119,7 +120,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, break; } - memcpy(out + outcnt, prev + start, 2 * count); + memcpy(out + 2 * outcnt, prev + 2 * start, 2 * count); } else { // copy from earlier in this frame int offset = (code & 0x1FFF) + 1; @@ -137,7 +138,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, if (outcnt < offset || maxcnt - outcnt < count) break; - av_memcpy_backptr((uint8_t *)out + 2 * outcnt, 2 * offset, 2 * count); + av_memcpy_backptr(out + 2 * outcnt, 2 * offset, 2 * count); } outcnt += count; } From b45e85ab7e5e3fc3f1b408fe2fd86c53ba649aa0 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Wed, 6 Mar 2013 00:38:12 +0100 Subject: [PATCH 3/4] Make 32bit zmbv colour-space opaque. --- libavcodec/zmbv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/zmbv.c b/libavcodec/zmbv.c index d1530e70e0..47b3468fe7 100644 --- a/libavcodec/zmbv.c +++ b/libavcodec/zmbv.c @@ -479,7 +479,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac c->bpp = 32; decode_intra = zmbv_decode_intra; c->decode_xor = zmbv_decode_xor_32; - avctx->pix_fmt = AV_PIX_FMT_BGRA; + avctx->pix_fmt = AV_PIX_FMT_BGR0; c->stride = c->width * 4; break; default: From 34e7a3d74cce2ba79905b8ed965c97c119364b39 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Wed, 6 Mar 2013 00:57:51 +0100 Subject: [PATCH 4/4] Move the iconv test to the bottom of configure. This fixes a possible mis-detection of iconv on OS X. OS X with macports often has two version of libiconv.2.dylib installed, one with symbols like "_iconv_open" and one with "_libiconv_open", so test for iconv with all flags to make sure the detection uses the same library as the actual compilation / linking. Tested-by: Paul Sturbaum --- configure | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/configure b/configure index fe49f57b5d..c1dcd55aeb 100755 --- a/configure +++ b/configure @@ -3888,7 +3888,6 @@ enabled avisynth && require2 vfw32 "windows.h vfw.h" AVIFileInit -lavifil32 enabled fontconfig && require_pkg_config fontconfig "fontconfig/fontconfig.h" FcInit enabled frei0r && { check_header frei0r.h || die "ERROR: frei0r.h header not found"; } enabled gnutls && require_pkg_config gnutls gnutls/gnutls.h gnutls_global_init -enabled iconv && { check_func_headers iconv.h iconv || check_lib2 iconv.h iconv -liconv || die "ERROR: iconv not found"; } enabled libiec61883 && require libiec61883 libiec61883/iec61883.h iec61883_cmp_connect -lraw1394 -lavc1394 -lrom1394 -liec61883 enabled libaacplus && require "libaacplus >= 2.0.0" aacplus.h aacplusEncOpen -laacplus enabled libass && require_pkg_config libass ass/ass.h ass_library_init @@ -4053,6 +4052,9 @@ enabled vdpau && check_cpp_condition vdpau/vdpau.h "defined VDP_DECODER_PROFILE_MPEG4_PART2_ASP" || disable vdpau +# Funny iconv installations are not unusual, so check it after all flags have been set +enabled iconv && { check_func_headers iconv.h iconv || check_lib2 iconv.h iconv -liconv || die "ERROR: iconv not found"; } + enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel" enabled coverage && add_cflags "-fprofile-arcs -ftest-coverage" && add_ldflags "-fprofile-arcs -ftest-coverage" test -n "$valgrind" && target_exec="$valgrind --error-exitcode=1 --malloc-fill=0x2a --track-origins=yes --leak-check=full --gen-suppressions=all --suppressions=$source_path/tests/fate-valgrind.supp"