Changeset 2f29e4ff655f3ad02ad22bbad4c3eca196ede762
- Timestamp:
- 19/07/07 00:14:57 (1 year ago)
- git-parent:
- Files:
-
- modules/demux/rawvid.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
modules/demux/rawvid.c
r6c9013a r2f29e4f 60 60 set_shortname( "Raw Video" ); 61 61 set_description( _("Raw video demuxer") ); 62 set_capability( "demux2", 2);62 set_capability( "demux2", 3 ); 63 63 set_category( CAT_INPUT ); 64 64 set_subcategory( SUBCAT_INPUT_DEMUX ); … … 86 86 87 87 mtime_t i_pcr; 88 89 vlc_bool_t b_y4m; 88 90 }; 89 91 … … 127 129 uint32_t i_chroma; 128 130 char *psz_aspect_ratio; 129 unsigned int i_aspect ;131 unsigned int i_aspect = 0; 130 132 struct preset_t *p_preset = NULL; 131 132 /* Check for YUV file extension */ 133 uint8_t *p_peek; 134 vlc_bool_t b_valid = VLC_FALSE; 135 vlc_bool_t b_y4m = VLC_FALSE; 136 137 if( stream_Peek( p_demux->s, &p_peek, 9 ) == 9 ) 138 { 139 /* http://wiki.multimedia.cx/index.php?title=YUV4MPEG2 */ 140 if( !strncmp( (char *)p_peek, "YUV4MPEG2", 9 ) ) 141 { 142 b_valid = VLC_TRUE; 143 b_y4m = VLC_TRUE; 144 } 145 } 146 133 147 psz_ext = strrchr( p_demux->psz_path, '.' ); 134 135 148 if( psz_ext ) 136 149 { … … 138 151 for( p_preset = p_presets; *p_preset->psz_ext; p_preset++ ) 139 152 if( !strcasecmp( psz_ext, p_preset->psz_ext ) ) 153 { 154 b_valid = VLC_TRUE; 140 155 break; 141 }142 if( ( !p_preset || !*p_preset->psz_ext ) &&143 strcmp(p_demux->psz_demux, "rawvid") )156 } 157 } 158 if( ( !b_valid ) && strcmp(p_demux->psz_demux, "rawvid") ) 144 159 { 145 160 return VLC_EGENERIC; … … 152 167 p_sys->i_pcr = 1; 153 168 169 p_sys->b_y4m = b_y4m; 154 170 p_sys->f_fps = var_CreateGetFloat( p_demux, "rawvid-fps" ); 155 171 i_width = var_CreateGetInteger( p_demux, "rawvid-width" ); … … 158 174 psz_aspect_ratio = var_CreateGetString( p_demux, "rawvid-aspect-ratio" ); 159 175 176 if( b_y4m ) 177 { 178 char *psz; 179 char *buf; 180 int a, b; 181 psz = stream_ReadLine( p_demux->s ); 182 183 /* TODO: handle interlacing */ 184 185 #define READ_FRAC( key, num, den ) \ 186 buf = strchr( psz+9, key );\ 187 if( buf )\ 188 {\ 189 char *end = strchr( buf, ' ' );\ 190 char *sep;\ 191 if( end ) *end = '\0';\ 192 sep = strchr( buf, ':' );\ 193 if( sep )\ 194 {\ 195 *sep = '\0';\ 196 den = atoi( sep+1 );\ 197 }\ 198 else\ 199 {\ 200 den = 1;\ 201 }\ 202 num = atoi( buf+1 );\ 203 if( sep ) *sep = ':';\ 204 if( end ) *end = ' ';\ 205 } 206 READ_FRAC( 'W', i_width, a ) 207 READ_FRAC( 'H', i_height, a ) 208 READ_FRAC( 'F', a, b ) 209 p_sys->f_fps = (double)a/(double)b; 210 READ_FRAC( 'A', a, b ) 211 if( b != 0 ) i_aspect = a * VOUT_ASPECT_FACTOR / b; 212 213 buf = strchr( psz+9, 'C' ); 214 if( buf ) 215 { 216 char *end = strchr( buf, ' ' ); 217 if( end ) *end = '\0'; 218 buf++; 219 if( !strncmp( buf, "C420jpeg", 8 ) ) 220 { 221 psz_chroma = strdup( "I420" ); 222 } 223 else if( !strncmp( buf, "C420paldv", 9 ) ) 224 { 225 psz_chroma = strdup( "I420" ); 226 } 227 else if( !strncmp( buf, "C420", 4 ) ) 228 { 229 psz_chroma = strdup( "I420" ); 230 } 231 else if( !strncmp( buf, "C422", 4 ) ) 232 { 233 psz_chroma = strdup( "I422" ); 234 } 235 else if( !strncmp( buf, "C444", 4 ) ) 236 { 237 psz_chroma = strdup( "I444" ); 238 } 239 else 240 { 241 msg_Warn( p_demux, "Unknown YUV4MPEG2 chroma type \"%s\"", 242 buf ); 243 } 244 if( end ) *end = ' '; 245 } 246 247 free( psz ); 248 } 249 160 250 if( p_preset && *p_preset->psz_ext ) 161 251 { … … 184 274 } 185 275 186 if( psz_aspect_ratio && *psz_aspect_ratio ) 187 { 188 char *psz_parser = strchr( psz_aspect_ratio, ':' ); 189 if( psz_parser ) 190 { 191 *psz_parser++ = '\0'; 192 i_aspect = atoi( psz_aspect_ratio ) * VOUT_ASPECT_FACTOR 193 / atoi( psz_parser ); 276 if( !i_aspect ) 277 { 278 if( psz_aspect_ratio && *psz_aspect_ratio ) 279 { 280 char *psz_parser = strchr( psz_aspect_ratio, ':' ); 281 if( psz_parser ) 282 { 283 *psz_parser++ = '\0'; 284 i_aspect = atoi( psz_aspect_ratio ) * VOUT_ASPECT_FACTOR 285 / atoi( psz_parser ); 286 } 287 else 288 { 289 i_aspect = atof( psz_aspect_ratio ) * VOUT_ASPECT_FACTOR; 290 } 194 291 } 195 292 else 196 293 { 197 i_aspect = atof( psz_aspect_ratio ) * VOUT_ASPECT_FACTOR; 198 } 199 } 200 else 201 { 202 i_aspect = i_width * VOUT_ASPECT_FACTOR / i_height; 294 i_aspect = i_width * VOUT_ASPECT_FACTOR / i_height; 295 } 203 296 } 204 297 free( psz_aspect_ratio ); … … 257 350 /* Call the pace control */ 258 351 es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_sys->i_pcr ); 352 353 if( p_sys->b_y4m ) 354 { 355 /* Skip the frame header */ 356 unsigned char psz_buf[10]; 357 psz_buf[9] = '\0'; 358 stream_Read( p_demux->s, psz_buf, strlen( "FRAME" ) ); 359 while( psz_buf[0] != 0x0a ) 360 { 361 if( stream_Read( p_demux->s, psz_buf, 1 ) < 1 ) 362 return 0; 363 } 364 } 259 365 260 366 if( ( p_block = stream_Block( p_demux->s, p_sys->frame_size ) ) == NULL )
