void MpegDemultiplexer::system_header() { ASSERT(m_file->m_next_code == 0x000001bb); uint16 header_length = m_file->getnbits(16); m_file->getmarkerbit(); m_file->getnbits(22);//rate_bound 22 m_file->getmarkerbit(); m_file->getnbits(6);//audio_bound 6 m_file->getbit();//fixed_flag 1 m_file->getbit();//CSPS_flag 1 m_file->getbit();//system_audio_lock_flag 1 m_file->getbit();//system_video_lock_flag 1 m_file->getmarkerbit(); m_file->getnbits(5);//video_bound 5 if (m_mpeg1) { uint8 reserved_byte = m_file->getnbits(8); ASSERT(reserved_byte == 0xFF); } else { int packet_rate_restriction_flag = m_file->getbit(); uint8 reserved_bits = m_file->getnbits(7); ASSERT(reserved_bits == 0x7F); } int nbits = 48; while (m_file->looknbits(1) == 1) { int stream_id = m_file->getnbits(8); int filler = m_file->getnbits(2);//'11' 2 ASSERT(filler == 3); if ((stream_id & 0xf0) == 0xe0) // video stream { if (FindStream(stream_id) == NULL) { MpegStream* pStream = new MpegStream; pStream->m_pFilter = this; pStream->m_stream_id = stream_id; m_streams.push_back(pStream); } } else if ((stream_id & 0xe0) == 0xc0) // audio stream { if (FindStream(stream_id) == NULL) { MpegStream* pStream = new MpegStream; pStream->m_pFilter = this; pStream->m_stream_id = stream_id; m_streams.push_back(pStream); } #if 0 if (FindStream(stream_id) == NULL) { CMPEGStream* pStream = new CMPEGStream; //CComObject<CMPEGStream>::CreateInstance(&pStream); //pStream->AddRef(); pStream->m_pFilter = this; pStream->m_id = L"Stream Output"; pStream->m_stream_id = stream_id; #if 0 // Don't actually connect yet pStream->m_connectedTo.CoCreateInstance(L"LMPEGAudio.LMPEGAudioDecoder"); #endif m_streams.AddTail((CMPEGStream*)pStream); AddPin(pStream); } #endif } int P_STD_buffer_bound_scale = m_file->getnbits(1); int P_STD_buffer_size_bound = m_file->getnbits(13); nbits += 1+7+2+1+13; } //m_file->ungetbits(1); int nbytes = (nbits + 7)/8; int N = header_length - nbytes; ASSERT(N == 0); m_file->next_start_code(); }
bool SCH_SHEET::Load( LINE_READER& aLine, wxString& aErrorMsg ) { int fieldNdx, size; SCH_SHEET_PIN* sheetPin; char* ptcar; SetTimeStamp( GetNewTimeStamp() ); // sheets are added to the GetDrawItems() like other schematic components. // however, in order to preserve the hierarchy (through m_Parent pointers), // a duplicate of the sheet is added to m_SubSheet array. // must be a duplicate, references just work for a two-layer structure. // this is accomplished through the Sync() function. if( ((char*)aLine)[0] == '$' ) // line should be "$Sheet" { if( !aLine.ReadLine() ) { aErrorMsg.Printf( wxT( "Read File Error" ) ); return false; } } /* Next line: must be "S xx yy nn mm" with xx, yy = sheet position * ( upper left corner ) et nn,mm = sheet size */ if( ( sscanf( &((char*)aLine)[1], "%d %d %d %d", &m_pos.x, &m_pos.y, &m_size.x, &m_size.y ) != 4 ) || ( ((char*)aLine)[0] != 'S' ) ) { aErrorMsg.Printf( wxT( " ** Eeschema file sheet struct error at line %d, aborted\n" ), aLine.LineNumber() ); aErrorMsg << FROM_UTF8( ((char*)aLine) ); return false; } /* Read fields */ for( ; ; ) /* Analysis of lines "Fn" text. */ { if( !aLine.ReadLine() ) return false; if( ((char*)aLine)[0] == 'U' ) { sscanf( ((char*)aLine) + 1, "%lX", &m_TimeStamp ); if( m_TimeStamp == 0 ) // zero is not unique! SetTimeStamp( GetNewTimeStamp() ); continue; } if( ((char*)aLine)[0] != 'F' ) break; sscanf( ((char*)aLine) + 1, "%d", &fieldNdx ); /* Read the field: * If fieldNdx> = 2: Fn "text" t s posx posy * If F0 "text" for SheetName * F1 and "text" for filename */ ptcar = ((char*)aLine); while( *ptcar && ( *ptcar != '"' ) ) ptcar++; if( *ptcar != '"' ) { aErrorMsg.Printf( wxT( "Eeschema file sheet label F%d at line %d, aborted\n" ), fieldNdx, aLine.LineNumber() ); aErrorMsg << FROM_UTF8( (char*) aLine ); return false; } wxString sheetName; ptcar += ReadDelimitedText( &sheetName, ptcar ); if( *ptcar == 0 ) { aErrorMsg.Printf( wxT( "Eeschema file sheet field F at line %d, aborted\n" ), aLine.LineNumber() ); aErrorMsg << FROM_UTF8( (char*) aLine ); return false; } if( ( fieldNdx == 0 ) || ( fieldNdx == 1 ) ) { if( sscanf( ptcar, "%d", &size ) != 1 ) { aErrorMsg.Printf( wxT( "Eeschema file sheet Label error line %d, aborted\n" ), aLine.LineNumber() ); aErrorMsg << FROM_UTF8( (char*) aLine ); } if( size == 0 ) size = DEFAULT_SIZE_TEXT; if( fieldNdx == 0 ) { m_name = sheetName; m_sheetNameSize = size; } else { SetFileName( sheetName ); m_fileNameSize = size; } } if( fieldNdx > 1 ) { sheetPin = new SCH_SHEET_PIN( this ); if( !sheetPin->Load( aLine, aErrorMsg ) ) { delete sheetPin; sheetPin = NULL; return false; } AddPin( sheetPin ); } } if( strnicmp( "$End", ((char*)aLine), 4 ) != 0 ) { aErrorMsg.Printf( wxT( "**Eeschema file end_sheet struct error at line %d, aborted\n" ), aLine.LineNumber() ); aErrorMsg << FROM_UTF8( ((char*)aLine) ); return false; } return true; }