int _update_by_id_subtest(istream& in, oid_t id, mark_base* ub) { char* data; mark_smart_ptr* x = 0; _get_data(in, data); x = new mark_smart_ptr(ub, id); cout << x -> its_oid() << "\n"; x -> update_usermark(data, strlen(data)); delete x; x = new mark_smart_ptr(ub, id); pstring* y = x->mark_value(); if ( y -> size() != strlen(data) || strcmp(y -> get(), data) != 0 ) { debug(cerr, y->size()); debug(cerr, (long)strlen(data)); debug(cerr, y -> get()); debug(cerr, data); throw(stringException("improperly updated mark")); } delete x; return 0; }
static ogg_int64_t _get_next_page(OggVorbis_File *vf,ogg_page *og, ogg_int64_t boundary){ if(boundary>0)boundary+=vf->offset; while(1){ long more; if(boundary>0 && vf->offset>=boundary)return(OV_FALSE); more=ogg_sync_pageseek(vf->oy,og); if(more<0){ /* skipped n bytes */ vf->offset-=more; }else{ if(more==0){ /* send more paramedics */ if(!boundary)return(OV_FALSE); { long ret=_get_data(vf); if(ret==0)return(OV_EOF); if(ret<0)return(OV_EREAD); } }else{ /* got a page. Return the offset at the page beginning, advance the internal offset past the page end */ ogg_int64_t ret=vf->offset; vf->offset+=more; return(ret); } } } }
/** * Get an object from table * * @param tbl qhasharr_t container pointer. * @param key key string * @param size if not NULL, oject size will be stored * * @return malloced object pointer if successful, otherwise(not found) * returns NULL * @retval errno will be set in error condition. * - ENOENT : No such key found. * - EINVAL : Invalid argument. * - ENOMEM : Memory allocation failed. * * @note * returned object must be freed after done using. */ void *qhasharr_get(qhasharr_t *tbl, const char *key, size_t key_size, size_t *val_size) { if (NULL == tbl || NULL == key) { errno = EINVAL; return NULL; } qhasharr_slot_t *_tbl_slots = NULL; qhasharr_init(tbl, &_tbl_slots); // get hash integer if (tbl->maxslots == 0) { return NULL; } unsigned int hash = qhashmurmur3_32(key, key_size) % tbl->maxslots; int idx = _get_idx(tbl, key, key_size, hash); if (idx < 0) { errno = ENOENT; return NULL; } return _get_data(tbl, idx, val_size); }
gpointer nm_auth_chain_get_data (NMAuthChain *self, const char *tag) { g_return_val_if_fail (self != NULL, NULL); g_return_val_if_fail (tag != NULL, NULL); return _get_data (self, tag); }
NMAuthCallResult nm_auth_chain_get_result (NMAuthChain *self, const char *permission) { gpointer data; g_return_val_if_fail (self != NULL, NM_AUTH_CALL_RESULT_UNKNOWN); g_return_val_if_fail (permission != NULL, NM_AUTH_CALL_RESULT_UNKNOWN); data = _get_data (self, permission); return data ? GPOINTER_TO_UINT (data) : NM_AUTH_CALL_RESULT_UNKNOWN; }
gulong nm_auth_chain_get_data_ulong (NMAuthChain *self, const char *tag) { gulong *data; g_return_val_if_fail (self != NULL, 0); g_return_val_if_fail (tag != NULL, 0); data = _get_data (self, tag); return data ? *data : 0ul; }
/** * Get next element. * * @param tbl qhasharr_t container pointer. * @param idx index pointer * * @return key name string if successful, otherwise(end of table) returns NULL * @retval errno will be set in error condition. * - ENOENT : No next element. * - EINVAL : Invald argument. * - ENOMEM : Memory allocation failed. * * @code * int idx = 0; * qnobj_t obj; * while(tbl->getnext(tbl, &obj, &idx) == true) { * printf("NAME=%s, DATA=%s, SIZE=%zu\n", * obj.name, (char*)obj.data, obj.size); * free(obj.name); * free(obj.data); * } * @endcode * * @note * Please be aware a key name will be returned with truncated length * because key name is truncated when it put into the table if it's length is * longer than _Q_HASHARR_KEYSIZE. */ bool qhasharr_getnext(qhasharr_t *tbl, qnobj_t *obj, int *idx) { if (NULL == tbl || NULL == obj || NULL == idx) { errno = EINVAL; return false; } qhasharr_slot_t *_tbl_slots = NULL; qhasharr_init(tbl, &_tbl_slots); for (; *idx < tbl->maxslots; (*idx)++) { if (_tbl_slots[*idx].count == 0 || _tbl_slots[*idx].count == -2) { continue; } size_t keylen = _tbl_slots[*idx].data.pair.keylen; if (keylen > _Q_HASHARR_KEYSIZE) keylen = _Q_HASHARR_KEYSIZE; obj->name = (char *)malloc(keylen); if (obj->name == NULL) { errno = ENOMEM; return false; } memcpy(obj->name, _tbl_slots[*idx].data.pair.key, keylen); obj->name_size = keylen; obj->data = _get_data(tbl, *idx, &obj->data_size); if (obj->data == NULL) { free(obj->name); obj->name = NULL; errno = ENOMEM; return false; } *idx += 1; return true; } errno = ENOENT; return false; }
/** * qhasharr->get(): Get an object from this table * * @param tbl qhasharr_t container pointer. * @param key key string * @param size if not NULL, oject size will be stored * * @return malloced object pointer if successful, otherwise(not found) * returns NULL * @retval errno will be set in error condition. * - ENOENT : No such key found. * - EINVAL : Invalid argument. * - ENOMEM : Memory allocation failed. * * @note * returned object must be freed after done using. */ static void *get(qhasharr_t *tbl, const char *key, size_t *size) { if (key == NULL) { errno = EINVAL; return NULL; } // get hash integer unsigned int hash = qhashmurmur3_32(key, strlen(key)) % tbl->maxslots; int idx = _get_idx(tbl, key, hash); if (idx < 0) { errno = ENOENT; return NULL; } return _get_data(tbl, idx, size); }
/** * qhasharr->getnext(): Get next element. * * @param tbl qhasharr_t container pointer. * @param idx index pointer * * @return key name string if successful, otherwise(end of table) returns NULL * @retval errno will be set in error condition. * - ENOENT : No next element. * - EINVAL : Invald argument. * - ENOMEM : Memory allocation failed. * * @code * int idx = 0; * qnobj_t obj; * while(tbl->getnext(tbl, &obj, &idx) == true) { * printf("NAME=%s, DATA=%s, SIZE=%zu\n", * obj.name, (char*)obj.data, obj.size); * free(obj.name); * free(obj.data); * } * @endcode * * @note * Please be aware a key name will be returned with truncated length * because key name is truncated when it put into the table if it's length is * longer than _Q_HASHARR_KEYSIZE. */ static bool getnext(qhasharr_t *tbl, qnobj_t *obj, int *idx) { if (tbl == NULL || obj == NULL || idx == NULL) { errno = EINVAL; return NULL; } qhasharr_data_t *data = tbl->data; for (; *idx < data->maxslots; (*idx)++) { if (data->slots[*idx].count == 0 || data->slots[*idx].count == -2) { continue; } size_t keylen = data->slots[*idx].data.pair.keylen; if (keylen > _Q_HASHARR_KEYSIZE) keylen = _Q_HASHARR_KEYSIZE; obj->name = (char *) malloc(keylen + 1); if (obj->name == NULL) { errno = ENOMEM; return false; } memcpy(obj->name, data->slots[*idx].data.pair.key, keylen); obj->name[keylen] = '\0'; obj->data = _get_data(tbl, *idx, &obj->size); if (obj->data == NULL) { free(obj->name); errno = ENOMEM; return false; } *idx += 1; return true; } errno = ENOENT; return false; }
////////////// // create // k \t locator // d \t data ////////////// int _create_subtest(char* buf, istream& in, mark_base* ub) { char* key, *data; mark_smart_ptr* x = 0; if ( strcmp(buf, "create") == 0 ) { cout << ">>> create:" << endl; _get_key(in, key); _get_data(in, data); cout << "---- new mark smtart_ptr ..." << endl; x = new mark_smart_ptr(ub, key); cout << "---- updating ..." << endl; x -> update_usermark(data, strlen(data)); delete x; cout << "<<< create:" << endl; } else return 1; }
BD_PRIVATE const uint8_t *libaacs_get_aacs_data(BD_AACS *p, int type) { if (!p || !p->aacs) { BD_DEBUG(DBG_BLURAY | DBG_CRIT, "get_aacs_data(%s): libaacs not initialized!\n", _type2str(type)); return NULL; } switch (type) { case BD_AACS_DISC_ID: return p->disc_id; case BD_AACS_MEDIA_VID: return _get_data(p, "aacs_get_vid"); case BD_AACS_MEDIA_PMSN: return _get_data(p, "aacs_get_pmsn"); case BD_AACS_DEVICE_BINDING_ID: return _get_data(p, "aacs_get_device_binding_id"); case BD_AACS_DEVICE_NONCE: return _get_data(p, "aacs_get_device_nonce"); case BD_AACS_MEDIA_KEY: return _get_data(p, "aacs_get_mk"); case BD_AACS_CONTENT_CERT_ID: return _get_data(p, "aacs_get_content_cert_id"); case BD_AACS_BDJ_ROOT_CERT_HASH: return _get_data(p, "aacs_get_bdj_root_cert_hash"); } BD_DEBUG(DBG_BLURAY | DBG_CRIT, "get_aacs_data(): unknown query %d\n", type); return NULL; }
kal_int32 _gif_sw_draw_internal( kal_int32 ox, kal_int32 oy, kal_bool is_resized, kal_int32 resized_width, kal_int32 resized_height, kal_uint8 *src, kal_uint32 size, kal_uint32 cache_id, kal_uint16 frame_number, kal_bool use_disposal_method, kal_bool transparent_enable, GIF_COLOR_FORMAT_ENUM gif_color_format, GIF_COLOR_FORMAT_ENUM palette_format) { /*----------------------------------------------------------------*/ /* Local Variables */ /*----------------------------------------------------------------*/ kal_int8 gif_done; kal_int32 frame_counter = 0; kal_uint16 transparent_index = 256; kal_uint16 temp_width, temp_height; kal_int32 n; kal_int16 lcd_idx; kal_int8 gif_is_hit_cache = 0; gif_sw_image_struct *cache; //kal_uint32 start, end; //kal_uint32 start_after_decode, end_after_decode; //start = drv_get_current_time(); //SW_GIF_TRACE(MOD_MMI, "[gif] - _gif_sw_draw_internal(): Enter.\n"); /*----------------------------------------------------------------*/ /* Code Body */ /*----------------------------------------------------------------*/ INIT_SRC(src, size); // try to hit the cache and initialize the cache item { kal_int32 offset; /* If the frame_counter<frame_number, gif will decode from frame_counter to frame_number. */ if (gif_sw_gif_hit_cache(cache_id, ox,oy, KAL_FALSE, frame_number, &lcd_idx, &frame_counter, &offset, KAL_TRUE)) { gif_is_hit_cache = 1; SEEK(offset); } cache = &g_gif_sw_cache[lcd_idx]; //pcurrent_match_gif_sw_cache = cache; } g_gif_sw_palette_size = 0; // ///////////////////////////////////////////////////////// // read the GIF file signature if (frame_counter == 0) { kal_uint32 header; kal_uint32 bg_color_idx = 0; header = _get_data(FSAL_ACCESS_U24, pfsal_handle); //GET_U24(header); if (header != 0x464947) /* 'GIF' */ { return GIF_SW_RET_FAILED; } /////////////////////////////////////////////////////////// // read the GIF dimension FLUSH(3); temp_width = _get_data(FSAL_ACCESS_U16, pfsal_handle); //GET_U16(temp_width); temp_height = _get_data(FSAL_ACCESS_U16, pfsal_handle); //GET_U16(temp_height); cache->image_width = temp_width; cache->image_height = temp_height; /* * Check the validity of clipping */ if (ox > g_gif_sw_dest_clipx2 || oy > g_gif_sw_dest_clipy2 || ox + temp_width - 1 < g_gif_sw_dest_clipx1 || oy + temp_height - 1 < g_gif_sw_dest_clipy1) { return GIF_SW_RET_SUCCEED; } /* ///////////////////////////////////////////////////////// */ /* * Read the global color palette */ n = _get_data(FSAL_ACCESS_U8, pfsal_handle); //GET_U8(n); bg_color_idx = _get_data(FSAL_ACCESS_U8, pfsal_handle); FLUSH(1); cache->has_gct = ((n & 0x80) > 0) ? 1 : 0; if (cache->has_gct) { kal_int32 i; gif_sw_color_from_rgb_func palette_color_from_rgb; n = 1 << ((n & 0x7) + 1); if (gif_color_format == GIF_SW_COLOR_FORMAT_8) { #if defined(GIF_SUPPORT_SET_PALETTE_FORMAT) palette_color_from_rgb = gif_sw_color_from_rgb_array[palette_format]; #else palette_color_from_rgb = GIF_SW_PALETTE_COLOR_FROM_RGB; #endif } else { palette_color_from_rgb = g_gif_sw_act_color_from_rgb; } /* Read the global color palette */ if (n) { g_gif_sw_palette_size = n; } for (i = 0; i < n; i++) { kal_uint8 R, G, B; R = _get_data(FSAL_ACCESS_U8, pfsal_handle); G = _get_data(FSAL_ACCESS_U8, pfsal_handle); B = _get_data(FSAL_ACCESS_U8, pfsal_handle); cache->palette[i] = palette_color_from_rgb(0xFF, R, G, B); if ((g_gif_sw_dest_source_key_enable && cache->palette[i] == g_gif_sw_dest_source_key) || (g_gif_sw_decoder_is_bypass_color && cache->palette[i] == g_gif_sw_decoder_bypass_color)) { cache->palette[i] ^= 1; } } /* current layer is index color layer */ if (gif_color_format == GIF_SW_COLOR_FORMAT_8) { for (i = 0; i < (kal_int32) n; i++) { if(g_gif_sw_layer_set_palette) (*g_gif_sw_layer_set_palette)((kal_uint8) i, cache->palette[i]); { cache->palette[i] = i; } } } } //_gif_sw_set_background_color((gif_sw_color) cache->palette[bg_color_idx]); //MAUI_03107299 g_gif_sw_cache[lcd_idx].original_background = g_gif_sw_background_color; } /* If resized width > original width or resized height > original height, do not resize */ if (!is_resized || resized_width > cache->image_width || resized_height > cache->image_height) { resized_width = cache->image_width; resized_height = cache->image_height; } /* don't process resized_width/resized_height == 0*/ if (resized_width == 0 || resized_height == 0) { return (GIF_SW_RET_SUCCEED); } /* first draw , we should keep 1 pixels background color for later used. */ if (!gif_is_hit_cache) { ////MAUI_03107299 //g_gif_sw_cache[lcd_idx].original_background = g_gif_sw_background_color; { kal_int32 x1; kal_int32 y1; x1 = ox; y1 = oy; if (x1 < g_gif_sw_dest_clipx1) { x1 = g_gif_sw_dest_clipx1; } if (y1 < g_gif_sw_dest_clipy1) { y1 = g_gif_sw_dest_clipy1; } /* If using disposal, alloc a memory to save the origianl background. */ /* If memory is not enougn, use the 1 pixel background color to redraw the background. */ /* Currently, only support "restore to background", not support "restore to previous". */ if (g_gif_sw_using_disposal) { g_gif_sw_cache[lcd_idx].disposal_bg_buf_size = (resized_width * resized_height * DRV_MAINLCD_BIT_PER_PIXEL) >> 3; g_gif_sw_cache[lcd_idx].disposal_bg_buf = (kal_uint8 *)g_gif_malloc(g_gif_sw_cache[lcd_idx].disposal_bg_buf_size); //SW_GIF_TRACE(MOD_MMI, "[gif_hal_dbg] - _gif_sw_draw_internal() g_gif_sw_using_disposal=KAL_TRUE \n"); if (g_gif_sw_cache[lcd_idx].disposal_bg_buf) { gif_sw_rect_struct dest_clip; dest_clip.x1 = 0; dest_clip.y1 = 0; dest_clip.x2 = resized_width - 1; dest_clip.y2 = resized_height - 1; /* copy the content of original background */ if(g_gif_sw_bitblt) { (*g_gif_sw_bitblt)( g_gif_sw_dest_buf_ptr, //dst g_gif_sw_dest_buf_width, x1, y1, resized_width, resized_height, cache->disposal_bg_buf, //src resized_width, 0, 0, dest_clip, DRV_MAINLCD_BIT_PER_PIXEL); //SW_GIF_TRACE(MOD_MMI, "[gif_hal_dbg] - _gif_sw_draw_internal() g_gif_sw_bitblt=KAL_TRUE \n"); } } } }
void _gif_sw_codec( kal_int32 GIF_ox, kal_int32 GIF_oy, kal_int32 resized_width, kal_int32 resized_height, kal_uint16 transparent_index, gif_sw_image_struct *cache, kal_int32 frame_counter, kal_bool transparent_enable, kal_bool isResized, GIF_COLOR_FORMAT_ENUM gif_color_format, GIF_COLOR_FORMAT_ENUM palette_format) { /*----------------------------------------------------------------*/ /* Local Variables */ /*----------------------------------------------------------------*/ kal_int32 src_clipx1, src_clipy1, src_clipx2, src_clipy2; int image_rows; int image_cols; kal_bool is_interlace; GIF_STATUS_ENUM status; /*----------------------------------------------------------------*/ /* Code Body */ /*----------------------------------------------------------------*/ //kal_uint32 start, end; //start = drv_get_current_time(); //SW_GIF_TRACE(MOD_MMI, "[gif] - _gif_sw_codec(): Enter. GIF(ox,oy)=(%d,%d), resized_width=%d, resized_height=%d\n", GIF_ox, GIF_oy, resized_width, resized_height); src_clipx1 = _get_data(FSAL_ACCESS_U16, pfsal_handle); /* X */ src_clipy1 = _get_data(FSAL_ACCESS_U16, pfsal_handle); /* Y */ image_cols = _get_data(FSAL_ACCESS_U16, pfsal_handle); /* W */ image_rows = _get_data(FSAL_ACCESS_U16, pfsal_handle); /* H */ src_clipx2 = src_clipx1 + image_cols - 1; src_clipy2 = src_clipy1 + image_rows - 1; // If need not to draw, still need to decode to get correct next frame position status = gif_sw_resizer_init( cache->image_width, cache->image_height, src_clipx1, src_clipy1, src_clipx2, src_clipy2, GIF_ox, GIF_oy, GIF_ox + resized_width - 1, GIF_oy + resized_height - 1, gif_color_format); if (status != GIF_STATUS_OK) { /* decode limitation, output width too large */ SW_GIF_TRACE(GIF_TRACE_MOD, "[gif] - _gif_sw_codec() Fail: output width too large \n"); //GIF_SW_RAISE(1); GIF_SW_RAISE(status); } cache->last_frame_x1 = (kal_int16) GIF_SW_RESIZER.want_dx1 - GIF_ox; cache->last_frame_y1 = (kal_int16) GIF_SW_RESIZER.want_dy1 - GIF_oy; cache->last_frame_x2 = (kal_int16) GIF_SW_RESIZER.want_dx2 - GIF_ox; cache->last_frame_y2 = (kal_int16) GIF_SW_RESIZER.want_dy2 - GIF_oy; { kal_int32 n; n = _get_data(FSAL_ACCESS_U8, pfsal_handle) & 0xFF; /* W05.39 Fix n value will be changed and the interlace attribute may be incorrect */ if (n & 0x40) { is_interlace = KAL_TRUE; } else { is_interlace = KAL_FALSE; } if (n & 0x80) { gif_sw_color_from_rgb_func palette_color_from_rgb; kal_int32 i; n = 1 << ((n & 0x7) + 1); g_gif_sw_current_palette = g_gif_sw_local_palette; if (gif_color_format == GIF_SW_COLOR_FORMAT_8) { #if defined(GIF_SUPPORT_SET_PALETTE_FORMAT) palette_color_from_rgb = gif_sw_color_from_rgb_array[palette_format]; #else palette_color_from_rgb = GIF_SW_PALETTE_COLOR_FROM_RGB; #endif } else { palette_color_from_rgb = g_gif_sw_act_color_from_rgb; } /* Read the local color palette */ if (n) { g_gif_sw_palette_size = n; } for (i = 0; i < n; i++) { kal_uint8 R, G, B; R = _get_data(FSAL_ACCESS_U8, pfsal_handle) & 0xFF; G = _get_data(FSAL_ACCESS_U8, pfsal_handle) & 0xFF; B = _get_data(FSAL_ACCESS_U8, pfsal_handle) & 0xFF; g_gif_sw_current_palette[i] = palette_color_from_rgb(0xFF, R, G, B); if ((g_gif_sw_dest_source_key_enable && g_gif_sw_current_palette[i] == g_gif_sw_dest_source_key) || (g_gif_sw_decoder_is_bypass_color && g_gif_sw_current_palette[i] == g_gif_sw_decoder_bypass_color)) { g_gif_sw_current_palette[i] ^= 1; } } /* current layer is index color layer */ if (gif_color_format == GIF_SW_COLOR_FORMAT_8) { for (i = 0; i < (kal_int32) n; i++) { if(g_gif_sw_layer_set_palette) { (*g_gif_sw_layer_set_palette)((kal_uint8) i, g_gif_sw_current_palette[i]); } g_gif_sw_current_palette[i] = i; } } } else /* use global palette */ { g_gif_sw_current_palette = cache->palette; } } { #define MaxStackSize 4096 #define NullCode (~0) int offset, y; register int x = 0; register unsigned char *c; register unsigned int datum; kal_uint32 consump_byte_cnt = 0; kal_uint32 read_byte_cnt = 0; kal_uint32 data_block_start_addr = 0; short *prefix; int count; unsigned char *packet, *pixel_stack, *suffix, *top_stack; unsigned int available, bits, clear, code, code_mask, code_size, data_size, first, end_of_information, in_code, old_code, pass; void (*put_pixel)(kal_int32* want_sx,gif_sw_color c,kal_bool want_draw); kal_int32 wantx = 0; kal_int32 wantx0 = 0; wantx0 = GIF_SW_RESIZER.want_start_sx;//(kal_int16)((((GIF_SW_RESIZER.want_start_dx - GIF_ox) * GIF_SW_RESIZER.src_width_range << 1) + GIF_SW_RESIZER.dest_width_range) / (GIF_SW_RESIZER.dest_width_range << 1)); put_pixel = put_pixel_with_transparent_enable; if (!transparent_enable) { put_pixel = put_pixel_with_transparent_disable; } /* allocate decoder tables */ { kal_uint8 *mem = (kal_uint8*) g_gif_sw_tree_buffer; prefix = (short*)mem; mem += MaxStackSize * sizeof(*prefix); suffix = (unsigned char*)mem; mem += MaxStackSize; pixel_stack = (unsigned char*)mem; /* use MaxStackSize+1 bytes; */ } /* Initialize GIF data stream decoder. */ data_size = _get_data(FSAL_ACCESS_U8, pfsal_handle) & 0xFF; if (data_size > 8) { SW_GIF_TRACE(GIF_TRACE_MOD, "[gif] - _gif_sw_codec() Fail: CorruptImage \n"); //GIF_SW_RAISE(1); /* CorruptImage */ GIF_SW_RAISE(GIF_STATUS_DEC_ERROR_INVALID_FILE); /* CorruptImage */ } clear = 1 << data_size; end_of_information = clear + 1; available = clear + 2; old_code = NullCode; code_size = data_size + 1; code_mask = (1 << code_size) - 1; for (code = 0; code < clear; code++) { prefix[code] = 0; suffix[code] = (unsigned char)code; } /* decode gif pixel stream */ datum = 0; bits = 0; c = 0; count = 0; first = 0; offset = 0; pass = 0; top_stack = pixel_stack; data_block_start_addr = _gif_fsal_tell(pfsal_handle); for (y = src_clipy1; y <= src_clipy2; y++) { if(g_gif_sw_image_progress_callback) { if(!(*g_gif_sw_image_progress_callback)()) { SW_GIF_TRACE(GIF_TRACE_MOD, "[gif] - _gif_sw_codec() Fail: GIF_SW_RET_DECODE_TIME_OUT. x=%d, y=%d \n", x, y); //GIF_SW_RAISE(GIF_SW_RET_DECODE_TIME_OUT); GIF_SW_RAISE(GIF_STATUS_DECODE_TIME_OUT); } } /* move to 0,offset */ wantx = wantx0; for (x = src_clipx1; x <= src_clipx2;) { kal_int32 decoded_pixel_count = 0; kal_int32 next_dst_data_distance = 0; /* ImageMagick Open Source Code Segment Start */ if (top_stack == pixel_stack) { if (bits < code_size) { /* Load bytes until there is enough bits for a code. */ if (count == 0) { /* Read a new data block. */ count = _get_data(FSAL_ACCESS_U8, pfsal_handle) & 0xFF; read_byte_cnt += count; if (count == 0) { break; } packet = (unsigned char*)g_gif_sw_stack; /* this will only use 256 bytes */ GETS(c, packet, count); } datum += ((unsigned int)(*c)) << bits; bits += 8; c++; count--; continue; } /* Get the next code. */ code = datum & code_mask; datum >>= code_size; bits -= code_size; /* Interpret the code */ if ((code > available) || (code == end_of_information)) { SW_GIF_TRACE(GIF_TRACE_MOD, "[gif] - _gif_sw_codec() Fail: Interpret the code \n"); FLUSH(count); while (!IS_EOF()) // skip he remaining data blocks of the frame. { count = _get_data(FSAL_ACCESS_U8, pfsal_handle) & 0xFF; if(count == 0) { break; } FLUSH(count); } return; } if (code == clear) { /* Reset decoder. */ code_size = data_size + 1; code_mask = (1 << code_size) - 1; available = clear + 2; old_code = NullCode; continue; } if (old_code == NullCode) { *top_stack++ = suffix[code]; old_code = code; first = code; continue; } in_code = code; if (code >= available) { *top_stack++ = (unsigned char)first; code = old_code; } while (code >= clear) { if ((top_stack - pixel_stack) >= MaxStackSize) { break; } *top_stack++ = suffix[code]; code = (unsigned int)prefix[code]; } first = (unsigned int)suffix[code]; /* Add a new string to the string table, */ if ((top_stack - pixel_stack) >= MaxStackSize) { SW_GIF_TRACE(GIF_TRACE_MOD, "[gif] - _gif_sw_codec() Fail: (top_stack - pixel_stack) >= MaxStackSize)\n"); break; } if (available >= MaxStackSize) { SW_GIF_TRACE(GIF_TRACE_MOD, "[gif] - _gif_sw_codec() Fail: available >= MaxStackSize\n"); break; } *top_stack++ = (unsigned char)first; prefix[available] = (short)old_code; suffix[available] = (unsigned char)first; available++; if (((available & code_mask) == 0) && (available < MaxStackSize)) { code_size++; code_mask += available; } old_code = in_code; } top_stack--; /* ImageMagick Open Source Code Segment End */ /* Pop a pixel off the pixel stack. */ if (isResized) { decoded_pixel_count = top_stack - pixel_stack; //how many decoded pixels if ((src_clipy1 + offset) == GIF_SW_RESIZER.want_sy) { if (wantx >= x) { next_dst_data_distance = wantx - x;// how long the distance including x } else { next_dst_data_distance = src_clipx2 - x; } if (decoded_pixel_count < next_dst_data_distance) { //it means all the decoded data this time shall be discarded. x += decoded_pixel_count; top_stack -= (decoded_pixel_count); } else { //some pixels in the decoded pixels shall be output to the dst image. x += next_dst_data_distance;//GIF_SW_RESIZER.want_sx; top_stack -= (next_dst_data_distance); } } else { //The source lineY shall be discarded for the resized image. //wantx shall be GIF_SW_RESIZER.want_sx_table for all x (no need to update wantx) if ((x + decoded_pixel_count) > src_clipx2) { next_dst_data_distance = src_clipx2 - x; } else { next_dst_data_distance = decoded_pixel_count; } x += next_dst_data_distance;//GIF_SW_RESIZER.want_sx; top_stack -= (next_dst_data_distance); } } if ((x == wantx) && ((src_clipy1 + offset) == GIF_SW_RESIZER.want_sy)) { kal_uint32 index = (kal_uint32) *top_stack; put_pixel(&wantx, ((gif_sw_color) g_gif_sw_current_palette[index]), ((kal_bool) (transparent_index != index))); } x++; } /* x loop */ gif_sw_resizer_update_wanty(&wantx, is_interlace); if (!is_interlace) { offset++; } else { switch (pass) { case 0: default: { offset += 8; if (offset >= image_rows) { pass++; offset = 4; } break; } case 1: { offset += 8; if (offset >= image_rows) { pass++; offset = 2; } break; } case 2: { offset += 4; if (offset >= image_rows) { pass++; offset = 1; } break; } case 3: { offset += 2; break; } } gif_sw_resizer_update_interlaced_want_sy(isResized, &wantx, src_clipy1 + offset); } if (x <= src_clipx2) { //SW_GIF_TRACE(MOD_MMI, "[gif] - _gif_sw_codec() Fail: x:%d <= src_clipx2:%d \n", x, src_clipx2); break; } } /* y loop */ if (y <= src_clipy2) { //SW_GIF_TRACE(MOD_MMI, "[gif] - _gif_sw_codec() Fail:y:%d <= src_clipy2:%d \n", y, src_clipy2); //GIF_SW_RAISE(1); GIF_SW_RAISE(GIF_STATUS_DEC_ERROR_PARSE); } //if (1) { kal_uint8 val; kal_int32 remaining_cnt; kal_uint32 len, curpos; curpos = _gif_fsal_tell(pfsal_handle); remaining_cnt = (data_block_start_addr + read_byte_cnt) - curpos; if (remaining_cnt > 0) { //kal_uint32 dbg_idx = 0; //for (dbg_idx = 0; dbg_idx < (remaining_cnt); dbg_idx++) //{ // val = _get_data(FSAL_ACCESS_U8, pfsal_handle) & 0xFF; // printf("Flush The Remaining %dth Byte = %d.\n", dbg_idx, val); //} FLUSH(remaining_cnt); //SW_GIF_TRACE(MOD_MMI, "[gif] - _gif_sw_codec(): Flush1 %d bytes.\n", remaining_cnt); } } //if (1) { kal_uint32 len, curpos; kal_uint8 val; len = 0; //Flush the remaining data. while (1) // skip data blocks { count = _get_data(FSAL_ACCESS_U8, pfsal_handle) & 0xFF; curpos = _gif_fsal_tell(pfsal_handle); len += count; if (count == 0) //Block Terminator { //printf("Count = 0, Flush %d data.\n", len); break; } FLUSH(count); //SW_GIF_TRACE(MOD_MMI, "[gif] - _gif_sw_codec(): Flush2 %d bytes.\n", count); //if (count > 0) //{ // kal_uint32 dbg_idx = 0; // for (dbg_idx = 0; dbg_idx < len; dbg_idx++) // { // val = _get_data(FSAL_ACCESS_U8, pfsal_handle) & 0xFF; // printf("Flush %dth byte = %d.\n", curpos+dbg_idx, val); // } //} } } } /* codec block */ //end = drv_get_current_time(); //SW_GIF_TRACE(MOD_MMI, "[gif] - _gif_sw_codec() End. %d ticks \n", drv_get_duration_tick(start, end)); //SW_GIF_TRACE(MOD_MMI, "[gif] - _gif_sw_codec(): Leave. FileCurPos = %d\n", _gif_fsal_tell(pfsal_handle)); }
__Type& operator*() { return _get_data(); }