This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

About 2432 x 2048 MJPEG of IPNC

Genius 3400 points

Hi all,

    According the IPNC 2.0, we modify the ipnc source to output 2432x2048 MJPEG. we had try more resolutions and found the limit of 2432, and we can get 2048x2048 MJPEG. When the image of width is up to 2048, we cannot get MJPEG from VLC, But in the encode thread,  we can save 2434x2048 JPEG pic.

    Who can help to give me some advice! Thanks a lot.

    Expect your reply!

  • Hi Gomo

    Look at ipnc 2.6.0 documentation :  Release_Notes_IPNC_DM36x.pdf, page 14 :

     • MegaPixel JPEG streaming at 5MP will not be played by ActiveX player due to limitation from RFC2435 (RTP Payload Format for JPEG-compressed Video)

    _____

    You could try rewrite  RTP receiving code in VLC.

    Regards,
    Marko.

     

     

  • Thanks for you reply!

     I had find some document about RFC2435,

     

    3.1.5.  Width: 8 bits

       This field encodes the width of the image in 8-pixel multiples (e.g.,   a width of 40 denotes an image 320 pixels wide).  The maximum width    is 2040 pixels.

    And it means 256 * (320/40) = 2048, have a multiple of 8 ; If we enlarge the  multiple to 16, the maximun width is 256 * 16 = 4096; 

    Is it correctly?  I do not  understand the relationship completly.

    Anybody can give me more information?  Or give me some advices to rewrite the RTP receiving?

    Thanks a lot!

     

  • Since there is also a "0" number  in every numerical system,  you have to subtract base value (which is a multiply factor), that is :
    2048 - 8 =2040
    4096-16=4080

  • Yes, I know to subtract the base value.

    I mean where to modify the base value? Can you give me more information?

    Thans again!

  • VLC uses Live555 for RTP/RTSP.

    You can look at Live555 source in a file  :  \live\liveMedia\JPEGVideoRTPSource.cpp,
    where you can change that multiply factor (8).

      // There's at least 8-byte video-specific header

      /*

    0                   1                   2                   3

    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1

    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

    | Type-specific |              Fragment Offset                  |

    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

    |      Type     |       Q       |     Width     |     Height    |

    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

      */

      if (packetSize < 8) return False;

     

      resultSpecialHeaderSize = 8;

     

      unsigned Offset = (unsigned)((DWORD)headerStart[1] << 16 | (DWORD)headerStart[2] << 8 | (DWORD)headerStart[3]);

      unsigned Type = (unsigned)headerStart[4];

      unsigned type = Type & 1;

      unsigned Q = (unsigned)headerStart[5];

      unsigned width = (unsigned)headerStart[6] * 8;

      unsigned height = (unsigned)headerStart[7] * 8;

      if ((width == 0 || height == 0) && fDefaultWidth != 0 && fDefaultHeight != 0) {

        // Use the default width and height parameters instead:

        width = fDefaultWidth;

        height = fDefaultHeight;

      }

      if (width == 0) width = 256*8; // special case

      if (height == 0) height = 256*8; // special case

     

      if (Type > 63) {

     

  • Thanks a lot! Today we had already resolve this problem!

    I had find the code just your mention. I debug to trace the code running and MJPEG stream not run these code, it run to soSpeialFrameHanding() in the \live\liveMedia\JPEGVideoRTPSink.cpp

    I modify the base value to 16, the client receive the width and height, and then multiply by 16. So the width and height can up to 4080 x 4080; It's enough to us.

     

    Thanks again.

     

  • gomo said:
    I modify the base value to 16, the client receive the width and height, and then multiply by 16. So the width and height can up to 4080 x 4080; It's enough to us.

    Hello, gomo!

    Can you share your patch?

  • Sorry, I have no patch.

    I can show you how to modify:

    Wis-streamer:

    WISJPEGStreamSource.cpp  Line 143

    /*
    fLastHeight = (fBuffer[i+5]<<5)|(fBuffer[i+6]>>3);
    fLastWidth = (fBuffer[i+7]<<5)|(fBuffer[i+8]>>3);
    */  

      int tHeight  = (fBuffer[i+5] << 8) | (fBuffer[i+6]);
      int tWidth = (fBuffer[i+7] << 8) | (fBuffer[i+8]);
    if( tWidth < 2040);
    {
       fLastHeight = (fBuffer[i+5]<<5)|(fBuffer[i+6]>>3);
       fLastWidth = (fBuffer[i+7]<<5)|(fBuffer[i+8]>>3);
    }
    else
    {
       fLastHeight = tHeight /16;
       fLastWidth = tWidth /16;
     } 

    Client: Live555,  JPEGVideoRTPSource.cpp  Function: processSpecialHeader

      unsigned width = (unsigned)headerStart[6] * 16;//8;
      unsigned height = (unsigned)headerStart[7] * 16;//8;

     We also meet a problem of MJPEG performace , See http://e2e.ti.com/support/dsp/davinci_digital_media_processors/f/100/t/149029.aspx

    If you have good idea, please tell me! 

  • Gomo, your post all change?

    I use it, but when I encode 5Mpx (2560x2048) I see only 1280x1024 on VLC 1.1.7

  • Hi,

        VLC can get 2048x2048 Mjpeg, you must modify VLC source of  receive header and rebuild.

       I did not modify the VLC, so you must do it by yourself. 

  • Ok, I set resolution to 2048x2048 and grab stream via openRTSP -m rtsrp://192.168.255.2/MJPEG (each frame to separate file) - file have resolution 1024x1024.

  • Set resolutin to 2048x2048, you can use VLC to get Mjpeg streamer;

    And you can down to 2040x2040, and try again, 

  • My client player use appro's activex ffmpeg control, it seems not Live555 but ffmpeg decode the rtp packet. Unfortunatly, I can not find the rtp decoder code, who know where  is it such as

    Live555,  JPEGVideoRTPSource.cpp  Function: processSpecialHeader

      unsigned width = (unsigned)headerStart[6] * 16;//8;
      unsigned height = (unsigned)headerStart[7] * 16;//8;

    in ffmpeg

  • hi,gomo,

    I have done you say above, the client the live555 transplantation to the MPlayer, live555 the following changes:

       JPEGVideoRTPSource.cpp 

      unsigned width = (unsigned)headerStart[6] * 16;
      unsigned height = (unsigned)headerStart[7] * 16;

     but the image is still not normal, my resolution is 2592 * 1920

    can you give me more information?

    thanks a lot!!

  • hi,gomo,

    Now,I can display properly, but the image resolution is only 1296*960,

    Please give me some help,thanks!

  • hi,

        Because the limitation of RFC2435, the largest size is 2048x2048 (256x8). So when your encode output is larger than 2048, you must change the ration.

        My resolution change ration 8 to 16. So in WISJPEGStreamSource.cpp,  we used our defined rule just like this.

    /*
    fLastHeight = (fBuffer[i+5]<<5)|(fBuffer[i+6]>>3);
    fLastWidth = (fBuffer[i+7]<<5)|(fBuffer[i+8]>>3);
    */  

      int tHeight  = (fBuffer[i+5] << 8) | (fBuffer[i+6]);
      int tWidth = (fBuffer[i+7] << 8) | (fBuffer[i+8]);
    if( tWidth < 2040);
    {
       fLastHeight = (fBuffer[i+5]<<5)|(fBuffer[i+6]>>3);
       fLastWidth = (fBuffer[i+7]<<5)|(fBuffer[i+8]>>3);
    }
    else
    {
       fLastHeight = tHeight /16;
       fLastWidth = tWidth /16;
     }

        In the client, we find the the place which parse the image resolution (w and h), add our defined rules, just like this

    Client: Live555,  JPEGVideoRTPSource.cpp  Function: processSpecialHeader

      unsigned width = (unsigned)headerStart[6] * 16;//8;
      unsigned height = (unsigned)headerStart[7] * 16;//8;

     So whatever you use tools, your must modify the rules in C/S.


  • xiaofeng xu68950 said:

    hi,gomo,

    I have done you say above, the client the live555 transplantation to the MPlayer, live555 the following changes:

       JPEGVideoRTPSource.cpp 

      unsigned width = (unsigned)headerStart[6] * 16;
      unsigned height = (unsigned)headerStart[7] * 16;

     but the image is still not normal, my resolution is 2592 * 1920

    can you give me more information?

    thanks a lot!!

    Look the image, the resolution is still not correct.

    You must check again. And you can save snap image from the Live555 directly, and use tool(WinHex) to modify the Jpeg resolution( w and H) by manual and the see the image whether is ok.

  • Glad to receive your reply,

    In accordance with what you said, Now, Images can already be displayed properly, but I found the images show only the source data (2592 * 1920)half of the image (1296 *960), 


    I do not know how to modify.

    can you give me some help?Thanks again

  • 1)Save a pic

     2)google to find the JPEG format, 

     3)use a tool (such ad WinHex) to go to the width and height,

     4)modify the value to  2592  1920, and save as

     5)use the image tool to open.

     6)See the picture whether is correct.  If the image is correct, It prove the resolution of parse  is wrong in the client.