[Re-Send] CR: Fix the issue that mjpeg thumbnail in avi container can not be displayed correctly

"Chen, Weian" <[email protected]>
Newsgroups gmane.comp.multimedia.helix.devel,gmane.spam.detected
Message-ID <CE50BAB9F318CF49AA37C2AE5CAC06EC25EAFE@pdsmsx412.ccr.corp.intel.com>
 

Please have a review..

 

Weian

________________________________

From: Chen, Weian 
Sent: 2008年6月24日 14:05
To: [email protected]
Cc: [email protected]
Subject: [helix-client-dev] CR: Fix the issue that mjpeg thumbnail in avi container can not be displayed correctly

 

Synopsis: 

  Fix the issue that mjpeg thumbnail in avi container can not be displayed correctly.

 

Overview: 

  The color space of decoded stream can be RGB or I420, and we do different color conversion for different format, then solve the mjpeg thumbnail issue, we used to regarding all decoded stream as RGB.

 

Files Added:

  None

 

Files Modified:

  player/hxclientkit/pub/HXClientCallbacks.h

  player/hxclientkit/src/platform/unix/CHXClientThumbnailUnix.cpp

  player/kit/dbus-server/pub/hxplayer.h

  player/kit/dbus-server/src/hxplayer.cpp

  player/kit/dbus-server/src/helix-dbus-server.cpp

 

Image Size and Heap Use impact (Client -Only):

  Little

 

Platforms and Profiles Affected:

  platform:   linux-2.2-libc6-gcc32-i586

  profile:     helix-client-all-defines

 

Distribution Libraries Affected:

  <libhxclient.a> <helix-dbus-server.bin>

 

Distribution library impact and planned action:

  <None>

 

Platforms and Profiles Build Verified:

  Set BIF branch   -> hxdbus_3_1_0_atlas

  Set Target(s)     -> dbus_server_with_video

  Set Profile       -> helix-client-all-defines

  System ID       -> linux-2.2-libc6-gcc32-i586

 

Branch: 

  HEAD, hxclient_3_1_0_atlas

 

Copyright assignment: <MUST be one of the following statements >

2.      Intel has signed and delivered a Joint Copyright Assignment

           to RealNetworks, and received acknowledgment that the 

           agreement was received.  

 

Files Attached:

  hxclient_thumbnail_mjpeg.diff

  dbus_server_thumbnail_mjpeg.diff

 

Weian

_______________________________________________
Helix-client-dev mailing list
[email protected]
http://lists.helixcommunity.org/mailman/listinfo/helix-client-dev
hxclient_thumbnail_mjpeg.diff (application/octet-stream, 1.6 KB)
Index: pub/HXClientCallbacks.h
===================================================================
RCS file: /cvsroot/player/hxclientkit/pub/HXClientCallbacks.h,v
retrieving revision 1.20.2.2
diff -u -w -r1.20.2.2 HXClientCallbacks.h
--- pub/HXClientCallbacks.h	16 May 2008 02:40:13 -0000	1.20.2.2
+++ pub/HXClientCallbacks.h	24 Jun 2008 03:37:43 -0000
@@ -51,6 +51,7 @@
 #define _HXCLIENT_CALLBACKS_H_
 
 #include "HXClientTypes.h"
+#define MAX_LEN 256
 
 typedef void ( *HXOnVisualStateChangedProcPtr ) ( void* userInfo, bool hasVisualContent );
 typedef void ( *HXOnIdealSizeChangedProcPtr ) ( void* userInfo, SInt32 idealWidth, SInt32 idealHeight );
@@ -146,6 +147,7 @@
 	UInt32 height;
 	UInt32 dataLen;
 	UInt32 bitsPerPixel;
+     char   mimeType[MAX_LEN];
 }
 HXThumbnailPicInfo;
 
Index: src/platform/unix/CHXClientThumbnailUnix.cpp
===================================================================
RCS file: /cvsroot/player/hxclientkit/src/platform/unix/CHXClientThumbnailUnix.cpp,v
retrieving revision 1.1.2.8
diff -u -w -r1.1.2.8 CHXClientThumbnailUnix.cpp
--- src/platform/unix/CHXClientThumbnailUnix.cpp	22 May 2008 02:49:11 -0000	1.1.2.8
+++ src/platform/unix/CHXClientThumbnailUnix.cpp	24 Jun 2008 03:38:08 -0000
@@ -825,6 +825,8 @@
     //printf ("CSourceInput::OnStreamHeader\n");
     IHXBuffer* pMime = NULL;
     pValues->GetPropertyCString("MimeType", pMime);
+    strncpy (thumbPicInfo.mimeType, pMime->GetBuffer(), pMime->GetSize());
+
     if( '\0' == g_sMimeType[0])
     {
         SafeStrCpy( g_sMimeType, pMime->GetBuffer(),MAX_MIME_TYPE_LENGTH);
dbus_server_thumbnail_mjpeg.diff (application/octet-stream, 4.9 KB)
? dbus_server_thumbnail_mjpeg.diff
Index: dbus-server/pub/hxplayer.h
===================================================================
RCS file: /cvsroot/player/kit/dbus-server/pub/hxplayer.h,v
retrieving revision 1.2.2.15
diff -u -w -r1.2.2.15 hxplayer.h
--- dbus-server/pub/hxplayer.h	5 Apr 2008 02:29:07 -0000	1.2.2.15
+++ dbus-server/pub/hxplayer.h	24 Jun 2008 03:34:47 -0000
@@ -86,12 +86,16 @@
     CColourConvert ();
     ~CColourConvert ();
     void InitTable ();
-    bool ConvertYUV420ToRgb32 (unsigned char *src0,
+    bool ConvertYUV420ToRgb24 (unsigned char *src0,
 					unsigned char *src1,
 					unsigned char *src2,
 					unsigned char *dst_ori,
 					int width,
 					int height);    
-    static int RGBRaw2PNG(const guchar* data, int width, int height, const char* filename);
+    bool ConvertRgb32ToRgb24 (unsigned char *src,
+                                        unsigned char *dst_ori,
+					int width,
+					int height);   
+    static int ConvertRGB24ToPNG(const guchar* data, int width, int height, const char* filename);
 };
 #endif /* _HXPLAYER_H */
Index: dbus-server/src/helix-dbus-server.cpp
===================================================================
RCS file: /cvsroot/player/kit/dbus-server/src/helix-dbus-server.cpp,v
retrieving revision 1.2.2.31
diff -u -w -r1.2.2.31 helix-dbus-server.cpp
--- dbus-server/src/helix-dbus-server.cpp	6 Jun 2008 18:11:41 -0000	1.2.2.31
+++ dbus-server/src/helix-dbus-server.cpp	24 Jun 2008 03:35:24 -0000
@@ -1358,7 +1358,10 @@
     {
     	char * pRgb = new char [pThumbPicInfo->width * pThumbPicInfo->height * 3];
 
-        retcode = rgbColourConvert.ConvertYUV420ToRgb32(pBuf,
+        if (!strcmp ("video/X-HX-I420", pThumbPicInfo->mimeType))
+        {
+
+            retcode = rgbColourConvert.ConvertYUV420ToRgb24(pBuf,
 					pBuf + pThumbPicInfo->width * pThumbPicInfo->height,
 					pBuf + pThumbPicInfo->width * pThumbPicInfo->height 
                                         + pThumbPicInfo->width * pThumbPicInfo->height  / 4,
@@ -1370,8 +1373,43 @@
             HX_DELETE (pThumbPicInfo);
             return;   
         }
+        }
+
+        else if (!strcmp ("video/X-HX-RGB", pThumbPicInfo->mimeType))
+        {
+            if (pThumbPicInfo->bitsPerPixel == 32)
+            {
+                retcode = rgbColourConvert.ConvertRgb32ToRgb24 (pBuf,
+                                            pRgb, pThumbPicInfo->width, pThumbPicInfo->height);
+            }
+            else if (pThumbPicInfo->bitsPerPixel == 24)
+            {
+                retcode = memcpy (pRgb, pBuf, pThumbPicInfo->width * pThumbPicInfo->height * 3);
+            }
+            else
+            {
+                HX_VECTOR_DELETE (pRgb);
+                HX_VECTOR_DELETE (pBuf);
+                HX_DELETE (pThumbPicInfo);
+                return;   
+            }
+
+            if(!retcode)
+            {
+                HX_VECTOR_DELETE (pRgb);
+                HX_VECTOR_DELETE (pBuf);
+                HX_DELETE (pThumbPicInfo);
+                return;   
+            }
+
+        }
+
+        else
+        {
+             return;
+        }
 
-    	retcode = rgbColourConvert.RGBRaw2PNG(pRgb, pThumbPicInfo->width, pThumbPicInfo->height, file);
+    	retcode = rgbColourConvert.ConvertRGB24ToPNG(pRgb, pThumbPicInfo->width, pThumbPicInfo->height, file);
         if(retcode)
         {
             HX_VECTOR_DELETE (pRgb);
Index: dbus-server/src/hxplayer.cpp
===================================================================
RCS file: /cvsroot/player/kit/dbus-server/src/hxplayer.cpp,v
retrieving revision 1.2.2.30
diff -u -w -r1.2.2.30 hxplayer.cpp
--- dbus-server/src/hxplayer.cpp	30 May 2008 06:00:44 -0000	1.2.2.30
+++ dbus-server/src/hxplayer.cpp	24 Jun 2008 03:36:00 -0000
@@ -1543,7 +1543,7 @@
         m_clp[ind++]=255;
 }
 
-bool CColourConvert::ConvertYUV420ToRgb32(unsigned char *src0,
+bool CColourConvert::ConvertYUV420ToRgb24(unsigned char *src0,
                                         unsigned char *src1,
                                         unsigned char *src2,
                                         unsigned char *dst_ori,
@@ -1618,7 +1618,28 @@
     return true;
 }
 
-static int CColourConvert::RGBRaw2PNG(const guchar* data, int width, int height, const char* filename)
+bool CColourConvert::ConvertRgb32ToRgb24 (unsigned char *src,
+					unsigned char *dst_ori,
+					int width,
+					int height)
+{
+    if (!src || !dst_ori)
+        return false;
+
+    if (width < 0 || height < 0)
+        return false;
+    
+    for (int i = 0; i < width * height; i++)
+    {
+        dst_ori [i * 3 + 0]= src [i * 4 + 2];
+        dst_ori [i * 3 + 1]= src [i * 4 + 1];
+        dst_ori [i * 3 + 2]= src [i * 4 + 0];
+    }
+
+    return true;
+}
+
+static int CColourConvert::ConvertRGB24ToPNG(const guchar* data, int width, int height, const char* filename)
 {
     //I'm using hardcode because i know the format of the data
     GdkPixbuf* pix_buf = NULL;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.