From 7fc4348f6499ecdfd6926d5e065e24a0d8a53ea6 Mon Sep 17 00:00:00 2001 From: Siana Gearz Date: Sat, 5 Jan 2013 22:14:10 +0100 Subject: [PATCH 1/4] Fix build deselect --- indra/newview/lltoolselect.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/indra/newview/lltoolselect.cpp b/indra/newview/lltoolselect.cpp index 403113e50..39cd470f3 100644 --- a/indra/newview/lltoolselect.cpp +++ b/indra/newview/lltoolselect.cpp @@ -88,7 +88,7 @@ LLObjectSelectionHandle LLToolSelect::handleObjectSelection(const LLPickInfo& pi } // [RLVa:KB] - Checked: 2010-11-29 (RLVa-1.3.0c) | Modified: RLVa-1.3.0c - if (rlv_handler_t::isEnabled()) + if ( (object) && (rlv_handler_t::isEnabled()) ) { if (!gRlvHandler.canEdit(object)) { @@ -109,7 +109,7 @@ LLObjectSelectionHandle LLToolSelect::handleObjectSelection(const LLPickInfo& pi } } - if ( (gRlvHandler.hasBehaviour(RLV_BHVR_FARTOUCH)) && (object) && ((!object->isAttachment()) || (!object->permYouOwner())) && + if ( (gRlvHandler.hasBehaviour(RLV_BHVR_FARTOUCH)) && ((!object->isAttachment()) || (!object->permYouOwner())) && (dist_vec_squared(gAgent.getPositionAgent(), object->getPositionRegion()) > 1.5f * 1.5f) ) { // NOTE-RLVa: see behaviour notes for a rather lengthy explanation of why we're doing things this way From 20ae72e5faaa7215633b75b1d0ec3dab916e9c9c Mon Sep 17 00:00:00 2001 From: Siana Gearz Date: Sat, 5 Jan 2013 23:25:47 +0100 Subject: [PATCH 2/4] CMake needs proper quoting --- indra/cmake/FMODEX.cmake | 48 +++++++++++++++------------------------- 1 file changed, 18 insertions(+), 30 deletions(-) diff --git a/indra/cmake/FMODEX.cmake b/indra/cmake/FMODEX.cmake index 902af05fb..dbac0ebac 100644 --- a/indra/cmake/FMODEX.cmake +++ b/indra/cmake/FMODEX.cmake @@ -2,18 +2,6 @@ include(Linking) -if(INSTALL_PROPRIETARY) - include(Prebuilt) - use_prebuilt_binary(fmodex) -endif(INSTALL_PROPRIETARY) - -find_library(FMODEX_LIBRARY - NAMES fmodex fmodexL fmodex_vc fmodexL_vc - PATHS - optimized ${ARCH_PREBUILT_DIRS_RELEASE} - debug ${ARCH_PREBUILT_DIRS_DEBUG} - ) - if (NOT FMODEX_LIBRARY) set(FMODEX_SDK_DIR CACHE PATH "Path to the FMOD Ex SDK.") if (FMODEX_SDK_DIR) @@ -21,19 +9,19 @@ if (NOT FMODEX_LIBRARY) find_library(FMODEX_LIBRARY fmodex_vc fmodexL_vc fmodex fmodexL PATHS - ${FMODEX_SDK_DIR}/api/lib - ${FMODEX_SDK_DIR}/api - ${FMODEX_SDK_DIR}/lib - ${FMODEX_SDK_DIR} + "${FMODEX_SDK_DIR}/api/lib" + "${FMODEX_SDK_DIR}/api" + "${FMODEX_SDK_DIR}/lib" + "${FMODEX_SDK_DIR}" ) elseif(WORD_SIZE EQUAL 64) find_library(FMODEX_LIBRARY fmodex64 fmodexL64 PATHS - ${FMODEX_SDK_DIR}/api/lib - ${FMODEX_SDK_DIR}/api - ${FMODEX_SDK_DIR}/lib - ${FMODEX_SDK_DIR} + "${FMODEX_SDK_DIR}/api/lib" + "${FMODEX_SDK_DIR}/api" + "${FMODEX_SDK_DIR}/lib" + "${FMODEX_SDK_DIR}" ) endif(WORD_SIZE EQUAL 32) endif(FMODEX_SDK_DIR) @@ -42,24 +30,24 @@ if (NOT FMODEX_LIBRARY) find_library(FMODEX_LIBRARY fmodex_vc fmodexL_vc PATHS - ${FMODEX_PROG_DIR}/api/lib - ${FMODEX_PROG_DIR}/api - ${FMODEX_PROG_DIR} + "${FMODEX_PROG_DIR}/api/lib" + "${FMODEX_PROG_DIR}/api" + "${FMODEX_PROG_DIR}" ) if(FMODEX_LIBRARY) message(STATUS "Found fmodex in ${FMODEX_PROG_DIR}") - set(FMODEX_SDK_DIR ${FMODEX_PROG_DIR}) - set(FMODEX_SDK_DIR ${FMODEX_PROG_DIR} CACHE PATH "Path to the FMOD Ex SDK." FORCE) + set(FMODEX_SDK_DIR "${FMODEX_PROG_DIR}") + set(FMODEX_SDK_DIR "${FMODEX_PROG_DIR}" CACHE PATH "Path to the FMOD Ex SDK." FORCE) endif(FMODEX_LIBRARY) endif(WINDOWS AND NOT FMODEX_LIBRARY) endif (NOT FMODEX_LIBRARY) find_path(FMODEX_INCLUDE_DIR fmod.hpp - ${LIBS_PREBUILT_DIR}/include/fmodex - ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/fmodex - ${FMODEX_SDK_DIR}/api/inc - ${FMODEX_SDK_DIR}/inc - ${FMODEX_SDK_DIR} + "${LIBS_PREBUILT_DIR}/include/fmodex" + "${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/fmodex" + "${FMODEX_SDK_DIR}/api/inc" + "${FMODEX_SDK_DIR}/inc" + "${FMODEX_SDK_DIR}" ) if(DARWIN) From d5892bbb32de66e1c3b2d519495152309b0c8f93 Mon Sep 17 00:00:00 2001 From: Siana Gearz Date: Sun, 6 Jan 2013 02:38:12 +0100 Subject: [PATCH 3/4] My preliminary thoughts on OpenJPEG --- indra/libopenjpeg/j2k.c | 46 ++++++++++++++++++++++------------------- indra/libopenjpeg/t1.c | 19 ++++++++++++++--- indra/libopenjpeg/tcd.c | 17 +++++++++------ 3 files changed, 52 insertions(+), 30 deletions(-) diff --git a/indra/libopenjpeg/j2k.c b/indra/libopenjpeg/j2k.c index b81bd579c..47ec0be3a 100644 --- a/indra/libopenjpeg/j2k.c +++ b/indra/libopenjpeg/j2k.c @@ -703,15 +703,15 @@ static void j2k_read_cox(opj_j2k_t *j2k, int compno) { /* If user wants to remove more resolutions than the codestream contains, return error*/ if (cp->reduce >= tccp->numresolutions) { opj_event_msg(j2k->cinfo, EVT_ERROR, "Error decoding component %d.\nThe number of resolutions to remove is higher than the number " - "of resolutions of this component\nModify the cp_reduce parameter.\n\n", compno); + "of resolutions of this component\nModify the cp_reduce parameter.\n\n", compno); j2k->state |= J2K_STATE_ERR; } - if( tccp->numresolutions > J2K_MAXRLVLS ) { - opj_event_msg(j2k->cinfo, EVT_ERROR, "Error decoding component %d.\nThe number of resolutions is too big: %d vs max= %d. Truncating.\n\n", - compno, tccp->numresolutions, J2K_MAXRLVLS); + if( tccp->numresolutions > J2K_MAXRLVLS ) { + opj_event_msg(j2k->cinfo, EVT_ERROR, "Error decoding component %d.\nThe number of resolutions is too big: %d vs max= %d. Truncating.\n\n", + compno, tccp->numresolutions, J2K_MAXRLVLS); j2k->state |= J2K_STATE_ERR; - tccp->numresolutions = J2K_MAXRLVLS; - } + tccp->numresolutions = J2K_MAXRLVLS; + } tccp->cblkw = cio_read(cio, 1) + 2; /* SPcox (E) */ tccp->cblkh = cio_read(cio, 1) + 2; /* SPcox (F) */ @@ -1516,27 +1516,31 @@ static void j2k_read_sod(opj_j2k_t *j2k) { if (len == cio_numbytesleft(cio) + 1) { truncate = 1; /* Case of a truncate codestream */ - } + } - {/* chop padding bytes: */ - unsigned char *s, *e; + {/* chop padding bytes: */ + unsigned char *s, *e; - s = cio_getbp(cio); - e = s + len; + s = cio_getbp(cio); + e = s + len; - if(len > 8) s = e - 8; + if(len > 8) s = e - 8; - if(e[-2] == 0x00 && e[-1] == 0x00) /* padding bytes */ - { - while(e > s) - { - if(e[-2] == 0xff && e[-1] == 0xd9) break; - --len; --e; truncate = 1; - } - } - } + if(e[-2] == 0x00 && e[-1] == 0x00) /* padding bytes */ + { + while(e > s) + { + if(e[-2] == 0xff && e[-1] == 0xd9) break; + --len; --e; truncate = 1; + } + } + } data = j2k->tile_data[curtileno]; + if(!(j2k->tile_len[curtileno] + len)) { + opj_event_msg(j2k->cinfo, EVT_WARNING, "SG Corrupt data length\n"); + return; + } data = (unsigned char*) opj_realloc(data, (j2k->tile_len[curtileno] + len) * sizeof(unsigned char)); data_ptr = data + j2k->tile_len[curtileno]; diff --git a/indra/libopenjpeg/t1.c b/indra/libopenjpeg/t1.c index ed9cdc3fe..93b997b79 100644 --- a/indra/libopenjpeg/t1.c +++ b/indra/libopenjpeg/t1.c @@ -1091,14 +1091,27 @@ static double t1_getwmsedec( int numcomps, int mct) { - double w1, w2, wmsedec; + double w1 = 1, w2, wmsedec; + + // Prevent running an MCT on more than 3 components. NB openjpeg v2.0 will support this via + // custom MCT tables that can be passed as encode parameters, 1.3 cannot support this as it + // uses a static table of 3 entries and there for can only cope with 3 components with out an + // array overflow + + if(numcomps==3) { + if (qmfbid == 1) { + w1 = (numcomps > 1) ? mct_getnorm(compno) : 1.0; + } else { + w1 = (numcomps > 1) ? mct_getnorm_real(compno) : 1.0; + } + } + if (qmfbid == 1) { - w1 = (mct && numcomps==3) ? mct_getnorm(compno) : 1.0; w2 = dwt_getnorm(level, orient); } else { /* if (qmfbid == 0) */ - w1 = (mct && numcomps==3) ? mct_getnorm_real(compno) : 1.0; w2 = dwt_getnorm_real(level, orient); } + wmsedec = w1 * w2 * stepsize * (1 << bpno); wmsedec *= wmsedec * nmsedec / 8192.0; diff --git a/indra/libopenjpeg/tcd.c b/indra/libopenjpeg/tcd.c index ee0520556..c19b3eb6a 100644 --- a/indra/libopenjpeg/tcd.c +++ b/indra/libopenjpeg/tcd.c @@ -1418,15 +1418,20 @@ opj_bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno int numres2decode; if (tcd->cp->reduce != 0) { - if ( tile->comps[compno].numresolutions < ( tcd->cp->reduce - 1 ) ) { + if ( tile->comps[compno].numresolutions < ( tcd->cp->reduce - 1 ) ) { opj_event_msg(tcd->cinfo, EVT_ERROR, "Error decoding tile. The number of resolutions to remove [%d+1] is higher than the number " - " of resolutions in the original codestream [%d]\nModify the cp_reduce parameter.\n", tcd->cp->reduce, tile->comps[compno].numresolutions); + " of resolutions in the original codestream [%d]\nModify the cp_reduce parameter.\n", tcd->cp->reduce, tile->comps[compno].numresolutions); return OPJ_FALSE; } - else { - tcd->image->comps[compno].resno_decoded = - tile->comps[compno].numresolutions - tcd->cp->reduce - 1; - } + else { + tcd->image->comps[compno].resno_decoded = + tile->comps[compno].numresolutions - tcd->cp->reduce - 1; + } + } + + if(!tilec->data) { + opj_event_msg(tcd->cinfo, EVT_ERROR, "Error decoding tile. null data\n"); + return OPJ_FALSE; } numres2decode = tcd->image->comps[compno].resno_decoded + 1; From cd27184332c99e599bb3120bc7d47b4dc7e81b78 Mon Sep 17 00:00:00 2001 From: Siana Gearz Date: Sun, 6 Jan 2013 04:01:28 +0100 Subject: [PATCH 4/4] Take out buggy padding removal in OJ --- indra/libopenjpeg/j2k.c | 46 ++++++----------------------------------- 1 file changed, 6 insertions(+), 40 deletions(-) diff --git a/indra/libopenjpeg/j2k.c b/indra/libopenjpeg/j2k.c index 47ec0be3a..21b462a34 100644 --- a/indra/libopenjpeg/j2k.c +++ b/indra/libopenjpeg/j2k.c @@ -1518,29 +1518,7 @@ static void j2k_read_sod(opj_j2k_t *j2k) { truncate = 1; /* Case of a truncate codestream */ } - {/* chop padding bytes: */ - unsigned char *s, *e; - - s = cio_getbp(cio); - e = s + len; - - if(len > 8) s = e - 8; - - if(e[-2] == 0x00 && e[-1] == 0x00) /* padding bytes */ - { - while(e > s) - { - if(e[-2] == 0xff && e[-1] == 0xd9) break; - --len; --e; truncate = 1; - } - } - } - data = j2k->tile_data[curtileno]; - if(!(j2k->tile_len[curtileno] + len)) { - opj_event_msg(j2k->cinfo, EVT_WARNING, "SG Corrupt data length\n"); - return; - } data = (unsigned char*) opj_realloc(data, (j2k->tile_len[curtileno] + len) * sizeof(unsigned char)); data_ptr = data + j2k->tile_len[curtileno]; @@ -1939,15 +1917,9 @@ opj_image_t* j2k_decode(opj_j2k_t *j2k, opj_cio_t *cio, opj_codestream_info_t *c #endif /* USE_JPWL */ if (id >> 8 != 0xff) { - if(cio_numbytesleft(cio) != 0) /* not end of file reached and no EOC */ - { - opj_event_msg(cinfo, EVT_ERROR, "%.8x: expected a marker instead of %x\n", cio_tell(cio) - 2, id); - opj_image_destroy(image); - return 0; - } - opj_event_msg(cinfo, EVT_WARNING, "%.8x: expected a marker instead of %x\n", cio_tell(cio) - 2, id); - j2k->state = J2K_STATE_NEOC; - break; + opj_image_destroy(image); + opj_event_msg(cinfo, EVT_ERROR, "%.8x: expected a marker instead of %x\n", cio_tell(cio) - 2, id); + return 0; } e = j2k_dec_mstab_lookup(id); /* Check if the marker is known*/ @@ -2041,15 +2013,9 @@ opj_image_t* j2k_decode_jpt_stream(opj_j2k_t *j2k, opj_cio_t *cio, opj_codestre id = cio_read(cio, 2); if (id >> 8 != 0xff) { - if(cio_numbytesleft(cio) != 0) /* no end of file reached and no EOC */ - { - opj_event_msg(cinfo, EVT_ERROR, "%.8x: expected a marker instead of %x\n", cio_tell(cio) - 2, id); - opj_image_destroy(image); - return 0; - } - opj_event_msg(cinfo, EVT_WARNING, "%.8x: expected a marker instead of %x\n", cio_tell(cio) - 2, id); - j2k->state = J2K_STATE_NEOC; - break; + opj_image_destroy(image); + opj_event_msg(cinfo, EVT_ERROR, "%.8x: expected a marker instead of %x\n", cio_tell(cio) - 2, id); + return 0; } e = j2k_dec_mstab_lookup(id); if (!(j2k->state & e->states)) {