/***************************************************************************** * FUNCTION * gdi_image_ab2_rle_decode_alpha * DESCRIPTION * Decode the RLE data stream with alpha. * PARAMETERS * dst_buf [IN] destination image buffer (the target to draw) * src_buf [IN] alpha blending source image buffer * rle_info [IN] RLE header data * draw_width [IN] pixels to draw a line * draw_height [IN] lines to draw * begin_ignore [IN] pixels to ignore before drawing * line_ignore [IN] pixels to ignore after drawing each line * RETURNS * void *****************************************************************************/ void gdi_image_ab2_rle_decode_alpha( gdi_image_ab2_img_buf_struct *dst_buf, const gdi_image_ab2_img_buf_struct *src_buf, const gdi_image_ab2_rle_info_struct *rle_info, U32 draw_width, U32 draw_height, U32 begin_ignore, U32 line_ignore) { /*----------------------------------------------------------------*/ /* Local Variables */ /*----------------------------------------------------------------*/ gdi_image_ab2_rle_ps_struct ps; U8 *dst_ptr, *src_ptr; U32 i; /*----------------------------------------------------------------*/ /* Code Body */ /*----------------------------------------------------------------*/ GDI_ASSERT(dst_buf != NULL); GDI_ASSERT(src_buf != NULL); GDI_ASSERT(rle_info != NULL); /* create a RLE pixel stream */ gdi_image_ab2_rle_ps_init(&ps, rle_info->bs_ptr, rle_info->color_idx_bits); /* Seek to the start position (ignore top clipping) */ gdi_image_ab2_rle_ps_ignore(&ps, begin_ignore); dst_ptr = dst_buf->ptr; src_ptr = src_buf->ptr; for (i = draw_height; i != 0; i--) { gdi_image_ab2_rle_ps_draw_alpha( &ps, rle_info, dst_ptr, src_ptr, dst_buf->pixel_bytes, src_buf->pixel_bytes, draw_width); /* Seek to the begin of next line */ gdi_image_ab2_rle_ps_ignore(&ps, line_ignore); dst_ptr += dst_buf->pitch_bytes; src_ptr += src_buf->pitch_bytes; } }
/***************************************************************************** * FUNCTION * gdi_image_ab2_bs_init * DESCRIPTION * Initialize the given bit-stream data structure. * The first data will start at given memory pointer. * PARAMETERS * bs [OUT] bit-stream structure to be initialized * mem_ptr [IN] start memory to be a bit-stream * RETURNS * void *****************************************************************************/ static GDI_IMAGE_AB2_INLINE void gdi_image_ab2_bs_init( gdi_image_ab2_bs_struct *bs, const U8 *mem_ptr) { /*----------------------------------------------------------------*/ /* Local Variables */ /*----------------------------------------------------------------*/ /*----------------------------------------------------------------*/ /* Code Body */ /*----------------------------------------------------------------*/ GDI_ASSERT(bs != NULL); if ((U32)mem_ptr & 0x1 != 0) { /* if mem_ptr is not 2-bytes alignment, read one byte into buffer */ bs->mem_ptr = mem_ptr + 1; bs->buf = *(U8 *) mem_ptr; bs->buf_bits = 8; } else { bs->mem_ptr = mem_ptr; bs->buf = 0; bs->buf_bits = 0; } }
/***************************************************************************** * FUNCTION * gdi_image_decoder_stop_all * DESCRIPTION * * PARAMETERS * void * RETURNS * *****************************************************************************/ GDI_RESULT gdi_image_decoder_stop_all(void) { /*----------------------------------------------------------------*/ /* Local Variables */ /*----------------------------------------------------------------*/ /*----------------------------------------------------------------*/ /* Code Body */ /*----------------------------------------------------------------*/ GDI_ENTER_CRITICAL_SECTION(gdi_image_decoder_stop_all) S16 next_idx; /* check if anything in decoder */ if (gdi_image_decoder_item_first_idx == -1) { GDI_RETURN(GDI_SUCCEED); } /* stop current running decoder */ switch (gdi_image_decoder_item_list[gdi_image_decoder_item_first_idx].img_type) { case GDI_IMAGE_TYPE_JPG_FILE: media_img_stop(MOD_MMI); break; default: GDI_ASSERT(0); } /* close file */ /* DRM_REPLACE */ /* FS_Close(gdi_image_decoder_item_list[gdi_image_decoder_item_first_idx].file_handle); */ DRM_close_file(gdi_image_decoder_item_list[gdi_image_decoder_item_first_idx].file_handle); next_idx = gdi_image_decoder_item_first_idx; while (next_idx != -1) { /* close all opened file */ if (gdi_image_decoder_item_list[next_idx].file_handle >= 0) { /* DRM_REPLACE */ /* FS_Close(gdi_image_decoder_item_list[next_idx].file_handle); */ DRM_close_file(gdi_image_decoder_item_list[next_idx].file_handle); gdi_image_decoder_item_list[next_idx].file_handle = -1; /* gdi_image_decoder_item_list[next_idx].file_size = 0; */ } gdi_image_decoder_item_list[next_idx].is_used = FALSE; next_idx = gdi_image_decoder_item_list[next_idx].next_idx; } gdi_image_decoder_item_first_idx = -1; gdi_image_decoder_item_last_idx = -1; GDI_RETURN(GDI_SUCCEED); GDI_EXIT_CRITICAL_SECTION(gdi_image_decoder_stop_all) }
/***************************************************************************** * FUNCTION * gdi_image_ab2_rle_ps_init * DESCRIPTION * Initialize RLE pixel stream data structure. * PARAMETERS * ps [OUT] the RLE pixel stream to be initialized * mem_ptr [IN] the start memory to be a RLE pixel stream * color_idx_bits [IN] the bits per color index * RETURNS * void *****************************************************************************/ void gdi_image_ab2_rle_ps_init( gdi_image_ab2_rle_ps_struct *ps, const U8 *mem_ptr, U32 color_idx_bits) { /*----------------------------------------------------------------*/ /* Local Variables */ /*----------------------------------------------------------------*/ /*----------------------------------------------------------------*/ /* Code Body */ /*----------------------------------------------------------------*/ GDI_ASSERT(ps != NULL); GDI_ASSERT(mem_ptr != NULL); gdi_image_ab2_bs_init(&ps->bs, mem_ptr); ps->color_idx_bits = color_idx_bits; ps->count = 0; ps->is_discount = 0; ps->repeat_color_idx = 0; }
/***************************************************************************** * FUNCTION * gdi_image_decoder_stop * DESCRIPTION * * PARAMETERS * handle [IN] * RETURNS * *****************************************************************************/ GDI_RESULT gdi_image_decoder_stop(gdi_handle handle) { /*----------------------------------------------------------------*/ /* Local Variables */ /*----------------------------------------------------------------*/ /*----------------------------------------------------------------*/ /* Code Body */ /*----------------------------------------------------------------*/ GDI_ENTER_CRITICAL_SECTION(gdi_image_decoder_stop) S16 this_idx; S16 prev_idx = -1; this_idx = gdi_image_decoder_item_first_idx; while (this_idx != -1) { if (handle == gdi_image_decoder_item_list[this_idx].seq_num) { /* stop jpeg decoderr driver */ if (this_idx == gdi_image_decoder_item_first_idx) { /* is the one that currently decoding - stop it */ /* handle each decoder's stop function */ switch (gdi_image_decoder_item_list[this_idx].img_type) { case GDI_IMAGE_TYPE_JPG_FILE: media_img_stop(MOD_MMI); break; default: GDI_ASSERT(0); } /* close file */ /* DRM_REPLACE */ /* FS_Close(gdi_image_decoder_item_list[this_idx].file_handle); */ DRM_close_file(gdi_image_decoder_item_list[this_idx].file_handle); gdi_image_decoder_item_list[this_idx].is_used = FALSE; gdi_image_decoder_item_first_idx = gdi_image_decoder_item_list[this_idx].next_idx; if (gdi_image_decoder_item_first_idx != -1) { gdi_image_decoder_decode_from_list(); } } else { /* not first one */ /* DRM_REPLACE */ /* FS_Close(gdi_image_decoder_item_list[this_idx].file_handle); */ DRM_close_file(gdi_image_decoder_item_list[this_idx].file_handle); /* file is successfully read into buffer, clear file handle */ gdi_image_decoder_item_list[this_idx].file_handle = -1; /* gdi_image_decoder_item_list[this_idx].file_size = 0; */ gdi_image_decoder_item_list[this_idx].is_used = FALSE; gdi_image_decoder_item_list[prev_idx].next_idx = gdi_image_decoder_item_list[this_idx].next_idx; } GDI_RETURN(GDI_SUCCEED); } prev_idx = this_idx; this_idx = gdi_image_decoder_item_list[this_idx].next_idx; } GDI_RETURN(GDI_IMAGE_DECODER_ERR_WRONG_HANDLE); GDI_EXIT_CRITICAL_SECTION(gdi_image_decoder_stop) }
/***************************************************************************** * FUNCTION * gdi_image_decoder_decode_from_list * DESCRIPTION * * PARAMETERS * void * RETURNS * *****************************************************************************/ GDI_RESULT gdi_image_decoder_decode_from_list(void) { /*----------------------------------------------------------------*/ /* Local Variables */ /*----------------------------------------------------------------*/ S16 idx; FS_HANDLE file_handle; media_img_decode_req_struct img_decode_data; /*----------------------------------------------------------------*/ /* Code Body */ /*----------------------------------------------------------------*/ if (gdi_image_decoder_item_first_idx != -1) { idx = gdi_image_decoder_item_first_idx; /* load image from file to buffer */ file_handle = gdi_image_decoder_item_list[idx].file_handle; memset(gdi_work_buffer, 0xff, gdi_image_decoder_frame_buf_size); img_decode_data.display_width = (kal_uint16) gdi_image_decoder_item_list[idx].dest_width; img_decode_data.display_height = (kal_uint16) gdi_image_decoder_item_list[idx].dest_height; img_decode_data.image_buffer_p = (void*)gdi_work_buffer; img_decode_data.image_buffer_size = (kal_uint32) gdi_image_decoder_frame_buf_size; img_decode_data.media_mode = (kal_uint16) MED_MODE_FILE; img_decode_data.media_type = (kal_uint16) MED_TYPE_JPG; img_decode_data.data = (void*)file_handle; img_decode_data.seq_num = (kal_uint16) gdi_image_decoder_item_list[idx].seq_num; img_decode_data.blocking = (kal_bool) FALSE; /* non blocking */ img_decode_data.image_clip_x1 = gdi_image_decoder_item_list[idx].output_clipx1; img_decode_data.image_clip_y1 = gdi_image_decoder_item_list[idx].output_clipy1; img_decode_data.image_clip_x2 = gdi_image_decoder_item_list[idx].output_clipx2; img_decode_data.image_clip_y2 = gdi_image_decoder_item_list[idx].output_clipy2; #ifdef GDI_HW_JPEG_SUPPORT_OUTPUT_ANOTHER_BUFFER img_decode_data.memory_output = gdi_memory_output; img_decode_data.memory_output_width = gdi_memory_output_width; img_decode_data.memory_output_height = gdi_memory_output_height; img_decode_data.memory_output_buffer_address = gdi_memory_output_buffer_address; img_decode_data.memory_output_buffer_size = gdi_memory_output_buffer_size; #endif /* GDI_HW_JPEG_SUPPORT_OUTPUT_ANOTHER_BUFFER */ #ifdef GDI_HW_JPEG_SUPPORT_DIRECT_OUTPUT_BUFFER img_decode_data.image_pitch_mode = FALSE; /* non blocking should not direct output to layer */ #endif img_decode_data.jpeg_thumbnail_mode = TRUE; #ifdef GDI_HW_JPEG_SUPPORT_COLOR_FORMAT switch (gdi_act_layer->vcf) { case GDI_COLOR_FORMAT_16: img_decode_data.image_data_format = IMGDMA_IBW_OUTPUT_RGB565; break; case GDI_COLOR_FORMAT_24: case GDI_COLOR_FORMAT_32: img_decode_data.image_data_format = IMGDMA_IBW_OUTPUT_RGB888; break; default: GDI_ASSERT(0); /* strange color format */ } #endif /* GDI_HW_JPEG_SUPPORT_COLOR_FORMAT */ img_decode_data.callback = NULL; /* call each image types decoder */ switch (gdi_image_decoder_item_list[idx].img_type) { case GDI_IMAGE_TYPE_JPG_FILE: media_img_decode(MOD_MMI, (void*)&img_decode_data); break; default: GDI_ASSERT(0); } return GDI_SUCCEED; } return GDI_SUCCEED; }
/***************************************************************************** * FUNCTION * gdi_fast_mutex_lock * DESCRIPTION * * PARAMETERS * void * RETURNS * void *****************************************************************************/ void gdi_fast_mutex_lock(void) { kal_taskid gdi_current_thread_id; U32 save_irq_mask; #ifdef DEMO_PROJECT GDI_ASSERT(gdi_mutex.front_guard == GDI_MUTEX_GUARD_PATTERN); GDI_ASSERT(gdi_mutex.rear_guard == GDI_MUTEX_GUARD_PATTERN); #endif /* DEMO_PROJECT */ if (INT_Exception_Enter) return; #if 0 /* under construction !*/ /* under construction !*/ #if 0 /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ #endif /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ #ifdef GDI_MUTEX_DEBUG_DUMP_STACK /* under construction !*/ /* under construction !*/ #endif // GDI_MUTEX_DEBUG /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ /* under construction !*/ #endif /* 0 */ save_irq_mask = SaveAndSetIRQMask(); if ((gdi_current_thread_id = kal_get_current_thread_ID()) != NULL) { if (gdi_current_thread_id != gdi_mutex.tid) { if(gdi_mutex.tid == gdc_thread_id) // Is current GDI user GDC task ( non-blocking task ) ? if(!gdi_nb_is_high_priority()) // Should we wait non-blocking finish ? gdi_image_set_abort(TRUE); // Force abort non-blocking job /* wait gdi mutex free */ while (gdi_mutex.cnt) { RestoreIRQMask(save_irq_mask); kal_sleep_task(1); /* waiting */ save_irq_mask = SaveAndSetIRQMask(); } gdi_mutex.cnt = 1; gdi_mutex.tid = gdi_current_thread_id; gdi_mutex_serial++; gdi_image_set_abort(FALSE); // disable force abort, because we had got the mutex #ifdef GDI_MUTEX_DEBUG_DUMP_STACK //Store Stack Status when gdi mutex lock INT_ExceptionDumpStack(gdi_mutex_stack_backup,(long*)gdi_current_thread_id); #endif // GDI_MUTEX_DEBUG } else { ++(gdi_mutex.cnt); } } RestoreIRQMask(save_irq_mask); }