[vlc-devel] commit: mjpeg demux: When looking trough the data for EOI, also check for SOIs and skip the next EOI if we do find a SOI. This is to handle JPEG images which have JPEG thumbnails in their EXIF data . (Derk-Jan Hartman )

git version control git at videolan.org
Wed Aug 20 16:41:55 CEST 2008


vlc | branch: master | Derk-Jan Hartman <hartman at videolan.org> | Wed Aug 20 16:42:37 2008 +0200| [f9afd65c766084dd74fb7aa0c8a89e116cf57c42] | committer: Derk-Jan Hartman 

mjpeg demux: When looking trough the data for EOI, also check for SOIs and skip the next EOI if we do find a SOI. This is to handle JPEG images which have JPEG thumbnails in their EXIF data.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f9afd65c766084dd74fb7aa0c8a89e116cf57c42
---

 modules/demux/mjpeg.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/modules/demux/mjpeg.c b/modules/demux/mjpeg.c
index f601d92..7f76650 100644
--- a/modules/demux/mjpeg.c
+++ b/modules/demux/mjpeg.c
@@ -81,6 +81,7 @@ struct demux_sys_t
     int             i_frame_size_estimate;
     const uint8_t   *p_peek;
     int             i_data_peeked;
+    int             i_level;
 };
 
 /*****************************************************************************
@@ -307,6 +308,7 @@ static int Open( vlc_object_t * p_this )
     p_demux->p_sys      = p_sys = malloc( sizeof( demux_sys_t ) );
     p_sys->p_es         = NULL;
     p_sys->i_time       = 0;
+    p_sys->i_level      = 0;
 
     p_sys->psz_separator = NULL;
     p_sys->i_frame_size_estimate = 15 * 1024;
@@ -324,6 +326,7 @@ static int Open( vlc_object_t * p_this )
         {
             msg_Dbg( p_demux, "JPEG SOI marker detected" );
             p_demux->pf_demux = MjpgDemux;
+            p_sys->i_level++;
         }
         else
         {
@@ -405,8 +408,14 @@ static int MjpgDemux( demux_t *p_demux )
         return 0;
     }
     i = 3;
+FIND_NEXT_EOI:
     while( !( 0xFF == p_sys->p_peek[i-1] && 0xD9 == p_sys->p_peek[i] ) )
     {
+        if( 0xFF == p_sys->p_peek[i-1] && 0xD8 == p_sys->p_peek[i] )
+        {
+            p_sys->i_level++;
+            msg_Dbg( p_demux, "we found another JPEG SOI at %d", i );
+        }
         i++;
         if( i >= p_sys->i_data_peeked )
         {
@@ -422,6 +431,10 @@ static int MjpgDemux( demux_t *p_demux )
     i++;
 
     msg_Dbg( p_demux, "JPEG EOI detected at %d", i );
+    p_sys->i_level--;
+
+    if( p_sys->i_level > 0 )
+        goto FIND_NEXT_EOI;
     return SendBlock( p_demux, i );
 }
 




More information about the vlc-devel mailing list