X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fdemux%2Fmjpeg.c;h=31a00e5ce26d58374b6dd872eef00a1920298c65;hb=1ce4f166a9653d8ee369862ee3111cce91af815d;hp=fff153f4bca26e411b6b86fad50767669a571707;hpb=05492281965ed211badf7e1f4c2220be720d3356;p=vlc diff --git a/modules/demux/mjpeg.c b/modules/demux/mjpeg.c index fff153f4bc..31a00e5ce2 100644 --- a/modules/demux/mjpeg.c +++ b/modules/demux/mjpeg.c @@ -36,8 +36,6 @@ #include #include -#include - /***************************************************************************** * Module descriptor *****************************************************************************/ @@ -128,7 +126,7 @@ static char* GetLine( demux_t *p_demux, int *p_pos ) int i; char *p_line; - while( *p_pos > p_sys->i_data_peeked ) + while( *p_pos >= p_sys->i_data_peeked ) { if( ! Peek( p_demux, false ) ) { @@ -147,9 +145,9 @@ static char* GetLine( demux_t *p_demux, int *p_pos ) { return NULL; } + p_buf = p_sys->p_peek + *p_pos; + i_size = p_sys->i_data_peeked - *p_pos; } - p_buf = p_sys->p_peek + *p_pos; - i_size = p_sys->i_data_peeked - *p_pos; } *p_pos += ( i + 1 ); if( i > 0 && '\r' == p_buf[i - 1] ) @@ -185,18 +183,19 @@ static bool CheckMimeHeader( demux_t *p_demux, int *p_header_size ) *p_header_size = -1; return false; } - if( p_sys->i_data_peeked < 3) + if( p_sys->i_data_peeked < 5) { msg_Err( p_demux, "data shortage" ); *p_header_size = -2; return false; } - if( strncmp( (char *)p_sys->p_peek, "--", 2 ) ) + if( strncmp( (char *)p_sys->p_peek, "--", 2 ) != 0 + && strncmp( (char *)p_sys->p_peek, "\r\n--", 4 ) != 0 ) { *p_header_size = 0; return false; } - i_pos = 2; + i_pos = *p_sys->p_peek == '-' ? 2 : 4; psz_line = GetLine( p_demux, &i_pos ); if( NULL == psz_line ) { @@ -277,7 +276,7 @@ static int SendBlock( demux_t *p_demux, int i ) } else { - p_block->i_dts = p_block->i_pts = p_sys->i_time; + p_block->i_dts = p_block->i_pts = VLC_TS_0 + p_sys->i_time; p_sys->i_time += p_sys->i_frame_length; } @@ -301,8 +300,8 @@ static int Open( vlc_object_t * p_this ) demux_t *p_demux = (demux_t*)p_this; demux_sys_t *p_sys; int i_size; - int b_matched = false; - vlc_value_t val; + bool b_matched = false; + float f_fps; p_demux->pf_control = Control; p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) ); @@ -339,8 +338,7 @@ static int Open( vlc_object_t * p_this ) } - var_Create( p_demux, "mjpeg-fps", VLC_VAR_FLOAT | VLC_VAR_DOINHERIT ); - var_Get( p_demux, "mjpeg-fps", &val ); + f_fps = var_CreateGetFloat( p_demux, "mjpeg-fps" ); p_sys->i_frame_length = 0; /* Check for jpeg file extension */ @@ -350,9 +348,9 @@ static int Open( vlc_object_t * p_this ) demux_IsPathExtension( p_demux, ".jpg" ) ) { p_sys->b_still = true; - if( val.f_float) + if( f_fps ) { - p_sys->i_still_length = 1000000.0 / val.f_float; + p_sys->i_still_length = 1000000.0 / f_fps; } else { @@ -360,13 +358,13 @@ static int Open( vlc_object_t * p_this ) p_sys->i_still_length = 1000000; } } - else if ( val.f_float ) + else if ( f_fps ) { - p_sys->i_frame_length = 1000000.0 / val.f_float; + p_sys->i_frame_length = 1000000.0 / f_fps; } es_format_Init( &p_sys->fmt, VIDEO_ES, 0 ); - p_sys->fmt.i_codec = VLC_FOURCC('m','j','p','g'); + p_sys->fmt.i_codec = VLC_CODEC_MJPG; p_sys->p_es = es_out_Add( p_demux->out, &p_sys->fmt ); return VLC_SUCCESS;