Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Regarding Image re sizing using Tiva c series MCU and Keil as IDE.

Regarding Image re sizing using Tiva c series MCU and Keil as IDE.

Scheduled Pinned Locked Moved C / C++ / MFC
visual-studiocomhardwarebusinessperformance
10 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 10799357
    wrote on last edited by
    #1

    Hi all, I Sreenivasa, new to embedded and I am writing a application that needs to re size an image(Jpeg format) and these are my requirements: * C * Keil as ide. * Image format is JPEG to JPEG. So for I tried with the open source code in the below link http://code.google.com/p/picojpeg/ It works fine but it needs more than 32K of memory allocation, but my MCU is having only 32k of RAM. Any help is appreciated. thanks Srini

    CPalliniC 1 Reply Last reply
    0
    • U User 10799357

      Hi all, I Sreenivasa, new to embedded and I am writing a application that needs to re size an image(Jpeg format) and these are my requirements: * C * Keil as ide. * Image format is JPEG to JPEG. So for I tried with the open source code in the below link http://code.google.com/p/picojpeg/ It works fine but it needs more than 32K of memory allocation, but my MCU is having only 32k of RAM. Any help is appreciated. thanks Srini

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #2

      From the very picojpeg page[^]:

      Optimized for minimal memory consumption: Uses only ~2.3KB of work memory.

      THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?! -- C++ FQA Lite

      In testa che avete, signor di Ceprano?

      U 1 Reply Last reply
      0
      • CPalliniC CPallini

        From the very picojpeg page[^]:

        Optimized for minimal memory consumption: Uses only ~2.3KB of work memory.

        THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?! -- C++ FQA Lite

        U Offline
        U Offline
        User 10799357
        wrote on last edited by
        #3

        Pallini, They said the code memory consumption 2.3kb, not the code uses. actually while resizing an image of 1MB file, it reduces the size by taking the first pixel of each 8x8 block, so for that they will allocate the size of >32 kb of memory. thanks srini

        CPalliniC 1 Reply Last reply
        0
        • U User 10799357

          Pallini, They said the code memory consumption 2.3kb, not the code uses. actually while resizing an image of 1MB file, it reduces the size by taking the first pixel of each 8x8 block, so for that they will allocate the size of >32 kb of memory. thanks srini

          CPalliniC Offline
          CPalliniC Offline
          CPallini
          wrote on last edited by
          #4

          As far as I can understand you haven't to keep the whole image in RAM, have you?

          THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?! -- C++ FQA Lite

          In testa che avete, signor di Ceprano?

          U 1 Reply Last reply
          0
          • CPalliniC CPallini

            As far as I can understand you haven't to keep the whole image in RAM, have you?

            THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?! -- C++ FQA Lite

            U Offline
            U Offline
            User 10799357
            wrote on last edited by
            #5

            hi CPallini, Actually for using malloc we need to allocate heap space in startup.s file, here its allowing only 1000k of memory and if I enter 2000k it will throw error as "there is no space in execution region", so when it try to access the memory at 35k it will show error, below is the code where it is getting stuck. pImage = (uint8 *)malloc(row_pitch * decoded_height);// here the size of allocation is >32kb. if (!pImage) { fclose(g_pInFile); return NULL; } row_blocks_per_mcu = image_info.m_MCUWidth >> 3; col_blocks_per_mcu = image_info.m_MCUHeight >> 3; for ( ; ; ) { int y, x; uint8 *pDst_row; status = pjpeg_decode_mcu(); if (status) { if (status != PJPG_NO_MORE_BLOCKS) { printf("pjpeg_decode_mcu() failed with status %u\n", status); free(pImage); fclose(g_pInFile); return NULL; } break; } if (mcu_y >= image_info.m_MCUSPerCol) { free(pImage); fclose(g_pInFile); return NULL; } if (reduce) { // In reduce mode, only the first pixel of each 8x8 block is valid. pDst_row = pImage + mcu_y * col_blocks_per_mcu * row_pitch + mcu_x * row_blocks_per_mcu * image_info.m_comps; if (image_info.m_scanType == PJPG_GRAYSCALE) { *pDst_row = image_info.m_pMCUBufR[0]; } else { uint y, x; for (y = 0; y < col_blocks_per_mcu; y++) { uint src_ofs = (y * 128); for (x = 0; x < row_blocks_per_mcu; x++) { pDst_row[0] = image_info.m_pMCUBufR[src_ofs]; // Here the error occurs. pDst_row[1] = image_info.m_pMCUBufG[src_ofs]; pDst_row[2] = image_info.m_pMCUBufB[src_ofs]; pDst_row += 3; src_ofs += 64; } pDst_row += row_pitch - 3 * row_blocks_per_mcu; } } } mcu_x++; if (mcu_x == image_info.m_MCUSPerRow) { mcu_x = 0; mcu_y++; } } fclose(g_pInFile); *x = decoded_width; *y = decoded_height; *comps = image_info.m_comps; return pImage; thanks srini

            CPalliniC 1 Reply Last reply
            0
            • U User 10799357

              hi CPallini, Actually for using malloc we need to allocate heap space in startup.s file, here its allowing only 1000k of memory and if I enter 2000k it will throw error as "there is no space in execution region", so when it try to access the memory at 35k it will show error, below is the code where it is getting stuck. pImage = (uint8 *)malloc(row_pitch * decoded_height);// here the size of allocation is >32kb. if (!pImage) { fclose(g_pInFile); return NULL; } row_blocks_per_mcu = image_info.m_MCUWidth >> 3; col_blocks_per_mcu = image_info.m_MCUHeight >> 3; for ( ; ; ) { int y, x; uint8 *pDst_row; status = pjpeg_decode_mcu(); if (status) { if (status != PJPG_NO_MORE_BLOCKS) { printf("pjpeg_decode_mcu() failed with status %u\n", status); free(pImage); fclose(g_pInFile); return NULL; } break; } if (mcu_y >= image_info.m_MCUSPerCol) { free(pImage); fclose(g_pInFile); return NULL; } if (reduce) { // In reduce mode, only the first pixel of each 8x8 block is valid. pDst_row = pImage + mcu_y * col_blocks_per_mcu * row_pitch + mcu_x * row_blocks_per_mcu * image_info.m_comps; if (image_info.m_scanType == PJPG_GRAYSCALE) { *pDst_row = image_info.m_pMCUBufR[0]; } else { uint y, x; for (y = 0; y < col_blocks_per_mcu; y++) { uint src_ofs = (y * 128); for (x = 0; x < row_blocks_per_mcu; x++) { pDst_row[0] = image_info.m_pMCUBufR[src_ofs]; // Here the error occurs. pDst_row[1] = image_info.m_pMCUBufG[src_ofs]; pDst_row[2] = image_info.m_pMCUBufB[src_ofs]; pDst_row += 3; src_ofs += 64; } pDst_row += row_pitch - 3 * row_blocks_per_mcu; } } } mcu_x++; if (mcu_x == image_info.m_MCUSPerRow) { mcu_x = 0; mcu_y++; } } fclose(g_pInFile); *x = decoded_width; *y = decoded_height; *comps = image_info.m_comps; return pImage; thanks srini

              CPalliniC Offline
              CPalliniC Offline
              CPallini
              wrote on last edited by
              #6

              Am I missing something? The library author claims: "Written entirely in C, no reliance at all on the C run-time library (it includes no headers other than picojpeg.h), and does not use any dynamic memory allocation."

              THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?! -- C++ FQA Lite

              In testa che avete, signor di Ceprano?

              U 1 Reply Last reply
              0
              • CPalliniC CPallini

                Am I missing something? The library author claims: "Written entirely in C, no reliance at all on the C run-time library (it includes no headers other than picojpeg.h), and does not use any dynamic memory allocation."

                THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?! -- C++ FQA Lite

                U Offline
                U Offline
                User 10799357
                wrote on last edited by
                #7

                Hi pallini, I have used visual C++ 2008 express edition to execute the code and works fine, Since we are using Kiel as our IDE I did some minor changes. Yes only one header file(picojpeg.h) and they have used malloc in jpg2tga.c file

                CPalliniC 1 Reply Last reply
                0
                • U User 10799357

                  Hi pallini, I have used visual C++ 2008 express edition to execute the code and works fine, Since we are using Kiel as our IDE I did some minor changes. Yes only one header file(picojpeg.h) and they have used malloc in jpg2tga.c file

                  CPalliniC Offline
                  CPalliniC Offline
                  CPallini
                  wrote on last edited by
                  #8

                  Member 10833501 wrote:

                  they have used malloc in jpg2tga.c file

                  They? jpg2tga? Quoting again 'them':

                  picojpeg is a public domain JPEG decompressor written in plain C in a single source file picojpeg.c and a single header picojpeg.h"

                  and actually there is no malloc in picojpeg.c file.

                  THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?! -- C++ FQA Lite

                  In testa che avete, signor di Ceprano?

                  U 1 Reply Last reply
                  0
                  • CPalliniC CPallini

                    Member 10833501 wrote:

                    they have used malloc in jpg2tga.c file

                    They? jpg2tga? Quoting again 'them':

                    picojpeg is a public domain JPEG decompressor written in plain C in a single source file picojpeg.c and a single header picojpeg.h"

                    and actually there is no malloc in picojpeg.c file.

                    THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?! -- C++ FQA Lite

                    U Offline
                    U Offline
                    User 10799357
                    wrote on last edited by
                    #9

                    hi pallini, Source package is having 2 source files 1) picojpeg.c and jpg2tga.c For your reerence I am attaching the link again here ">http://code.google.com/p/picojpeg/" thanks srini

                    CPalliniC 1 Reply Last reply
                    0
                    • U User 10799357

                      hi pallini, Source package is having 2 source files 1) picojpeg.c and jpg2tga.c For your reerence I am attaching the link again here ">http://code.google.com/p/picojpeg/" thanks srini

                      CPalliniC Offline
                      CPalliniC Offline
                      CPallini
                      wrote on last edited by
                      #10

                      jpg2tga.cpp is not actually part of the library. It is an example program. However, if you really need such a functionality you could try to modify the code (if possible) to fit your needs. Another option could be using an external (serial) RAM.

                      THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?! -- C++ FQA Lite

                      In testa che avete, signor di Ceprano?

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups