AnsweredAssumed Answered

Save frames to hard drive using Video Input-Output project of adsp bf561

Question asked by Lelouch on Mar 17, 2014
Latest reply on Apr 4, 2014 by Suraj

So, I want to save frames that stored in SDRAM by using Video Input-Output project of kit adsp bf561

I include 2 new files to sub project "Core A' of this project (YCbCrtoRGB.asm to convert YUV 444 format to RGB format; Create_BMP_RGB.c to create a bitmap image and saved it to computer hard drive)

I also edit the "Interrupt_Service.c" of "Core A" like this :

 

#include "main.h"

 

 

/********************************************************************************/

/***** Defines the interrupt service routines for CoreA                                                            *****/

/********************************************************************************/

void _YCbCrtoRGB (unsigned char input[], unsigned char out[],int N);

 

 

EX_INTERRUPT_HANDLER(PPI0_RxIsr) {

          unsigned char *Ptr, *Y, *Cb, *Cr;

          unsigned char *YCbCr;

          short *fimage;

          int i, j, k, oddfield;

          short temp;

 

 

          *pDMA1_0_IRQ_STATUS |= DMA_DONE;                    // acknowledge interrupt

 

 

          semaphore_frames_received = true;                    // signal core B that a frame was received

 

 

          ++current_in_Frame;

 

 

          current_in_Frame = (current_in_Frame) % 4;

 

 

          //          Partition the whole chunk of image read from the video decoder

          //          into Y, Cb and Cr planes

          Ptr = (unsigned char *) 0x00;

          Y = (unsigned char *) 0x0012FC00;

          Cb = (unsigned char *) 0x00195000;

          Cr = (unsigned char *) 0x001FA400;

 

 

          j = 0;                    //          Make a copy of Cb and Cr components

                                        //          and retrieve the missing pixels

          for (i = 0; i < (720*576); i += 2)

          {

                    Y[i] = Ptr[j+1];

                    Y[i+1] = Ptr[j+3];

 

 

                    Cb[i] = Ptr[j];

                    temp = (short) Ptr[j] + (short) Ptr[j+4];

                    Cb[i+1] = (unsigned char) (temp >> 1);

 

 

                    Cr[i] = Ptr[j+2];

                    temp = (short) Ptr[j+2] + (short) Ptr[j+6];

                    Cr[i+1] = (unsigned char) (temp >> 1);

 

 

                    j += 4;

          }

 

 

          //          The image, at this point, is interlaced (i.e Odd field on top,

          //          even field below)

          //          We form back the image here as a whole!

          YCbCr = (unsigned char *) 0x00;

          Ptr = (unsigned char *) 0x0012FC00;

 

 

          oddfield = 1;

          j = 0;

          k = 720*288;

          for (i = 0; i < (720*576*3); i += 3)

          {

                    if ((i%2160) == 0)

                              oddfield ^= 1;

 

 

                    if (oddfield == 0)

                    {

                              YCbCr[i] = Y[j];

                              YCbCr[i+1] = Cb[j];

                              YCbCr[i+2] = Cr[j];

                              j++;

                    }

 

 

                    if (oddfield == 1)

                    {

                              YCbCr[i] = Y[k];

                              YCbCr[i+1] = Cb[k];

                              YCbCr[i+2] = Cr[k];

                              k++;

                    }

          }

 

 

          /*          Do your image processing here          */

 

 

/****************************************************************************************/

//          Convert to color RGB image                                                                                                                                                                 //

/****************************************************************************************/

 

 

_YCbCrtoRGB (YCbCr, Ptr, (720*576*3));

 

 

 

 

 

 

 

 

           unsigned int line,t,n,iByte,

           Width1=720,

           Height1=576;

           n=0;

                    unsigned char *data_temp;

                    data_temp = (unsigned char *) 0x0025F800;

                    for (line=Height1; line> 0; line--){

            t=3*(line-1)*Width1;

            for(iByte=0; iByte< 3*Width1; iByte++){

                *(data_temp+n)=*(Ptr+t+iByte);

                n++;

            };

 

 

 

 

        }

 

 

 

 

    //Write BMP file

    create_BMP_RGB(720,576,data_temp);

 

 

}

 

 

 

 

 

 

EX_EXCEPTION_HANDLER(ex_handler_coreA) {

          while(1);

}

I can already save the image to the hard drive, but it's something like this http://i.imgur.com/KSfZdjT.png

 

I use the same method for Video Input project for kit adsp bf533, and the image I get is perfect.

 

Can anyone tell me where did I go wrong.

Outcomes