Stellaris launchpad based video player






 (stellaris launchpad playing 320x140 color video at 25 fps video)



Hi,
 I am introducing my new mad project, a video player using stellaris launchpad and a 320x240 color lcd which I got from seeedstudio.  I tried the lcd shield by connecting on an arduino board and loaded some example codes for the arduino and it was working fine. I made a small video player few months ago using atmega32 and a 128x128 color lcd. This time my lcd resolution is larger. I want to make a better video player this time, so I selected a 32bit processor with more speed and ram, and I already have one arm cortex m4 based board, the texas instruments stellaris launchpad board which I bought for 4.9$ (limited time offer).
      I checked the arduino library code and written the lcd code for stellaris. To display stuff more faster I connected 8 bits of portb of stellaris to the 8 bit bus of lcd. At first I have some problems and later I found that few bits of portb is shorted with some other bits using zero ohm resistor r9 and r10, so I removed those. This is for msp430 launchpad compatibilit and it started to work.  I displayed some patterns on lcd and confirmed it is working.
  Later I configured uart in stellaris and streamed the image pixel data from pc to stellais and displayed it on the lcd. I used python image library in pc to convert image to 320x240 resolution and to get the pixel data from it.
    Later I configured sd card and used my own old library written for avr. Copied a single image data to sd card from sector zero and read the data and displayed on lcd. Then I wrote a python code in pc which invokes ffmpeg to obtain frames of a particular video. The same script reads all the image frames in the same order write the pixel data to a single file in 16bit format. Now I got a single uncompressed 'video' file!. I copied it to sd card, right now I am not following any filesystem, just writing the data from sector zero of sd card using  command 'sudo video_data >/dev/mmcblk0'.  (warning) The above command will overwrite the boot sector, root directory etc etc of existing file system in the card and there after the memory card will be shown as corrupted and will need to format it if you need to use it again in a PC/mobile phone. All data will be lost after this action.
        Now my aim is to display (stream) the data from the sd card on lcd. For this I am using multiple sector read command for the sd card and I am not even reading data to any buffer, instead I am directly reading from spi and writing to lcd. To get the best speed I optimized the HAL for SPI by sacrificing little bit on the readability of the code. Right now without audio I can achieve a speed of around 40 fps.
        Later I added audio to the video file, here I need to apply simple math. Using ffpmeg I extracted audio from the video in 8 bit wav format. On adding few video byte to video_file I added few audio bytes in between according to the video/audio bitrate ratio.

 Math:
    Video frame rate = 25
    single video frame size = 320x140*2
    So total video bytes/second = 320x140*2*25 = 2240000
    Now  I selected audio byte rate as 22400 bytes/second.
    So video/audio = 100
    So accordingly I have to mix video and audio in the final uncompressed video file.

 I configured pwm in stelaris. Then copied the new generated uncompressed video file to sd card in the same manner I did earlier. Now in the display code I need to send the video bytes to lcd and audio byte to pwm, and it played video with sound and the quality was decent....Checkout the above video..

Pics:


Circuit:
 (only important connections are shown, Vdd, GND etc are not shown)


Code:
(note: Use under your own risk, I will not be responsible for any personal damage/...) 


Thanks to seeedstudio for providing the lcd for reviewing............

13 comments :

  1. I suppose link to seeedstudio is wrong. ;)

    ReplyDelete
  2. I knew that the stellaris launchpad was powerful, but not that much! pretty impresive. I got a question. Are you developing on linux? Code Composer for windows seems over bloated

    ReplyDelete
  3. Hi,
    I am using arm-none-eabi-gcc in linux. (build using summon's arm shell script)....

    Also I configured eclipse IDE for the stellaris launchpad by looking into a tutorial http://kernelhacks.blogspot.in/2012/11/the-complete-tutorial-for-stellaris_25.html

    If you don't have eclipse just goto the release folder and type make command in terminal, it will build the code if U have given the correct path for stellarisware library and required compiler tools...

    ReplyDelete
  4. Nice project. uDMA may be more suitable for this kind of data streaming though.

    ReplyDelete
  5. Really a nice and improvised project.
    Best of luck,

    Warm Regards,
    Boseji

    ReplyDelete
  6. hello, vinod will you please post how getting started with RTOS in Stellaris launchpad? is it possible to use micrium codes μC/OS-II in Stellaris launchpad? please give me a guidance..

    thanks,
    regards
    sunil

    ReplyDelete
  7. Hey vinod, Nice project. I appreciate for your work. Keep going and good luck.
    deals15

    ReplyDelete
  8. Hello,
    I am using stellaris lm3s8962. I had connected sdcard of kingston 4 Gb with micro controller using SPI mode and fatfs driver.. I had found problem in initialization in Sd card.

    Please tell your sd card specification so that I buy that and experiment with that card.

    ReplyDelete
  9. itz a great project...
    i like it very much,,
    hope you are the right person am looking for,,,,
    do you,,,have experience with radio chips such as cc2500 by TI??
    can you plz help me for my project ..
    thankyou,,,
    best of luck

    ReplyDelete
  10. Could we play music in list?
    And.. How to write list of music to SD Card and play one by one
    Thanks for sharing your project :D

    ReplyDelete
  11. hello
    I wanna build a snake game using the same device and i wanna use the LCD with the same driver.But whenever I give supply from the board the board stops working(it stays on but program doesn't run). So how did you meet the current and voltage specification of the LCD? From the board or externally ? Can you post detailed images and explain it ?

    ReplyDelete