Monthly Archives: January 2010

Fluctuated naive video bit rate in transport stream

The bit rate of MPEG-2 transport stream is defined in ISO/IEC 13818-1 Eq. 2-5. It’s actually quite simple: take two successive transport stream packets with PCR. Count the number of bits between these two packets. Divide it by the PCR … Continue reading

Posted in Uncategorized | 3 Comments

XPath evaluator in MSXML

MSXML comes with full XPath support. When XPath is used to select a node (or node list), you can just use IXMLDOMNode::selectSingleNode method. It’s quite easy. However, when XPath doesn’t return node(s), IXMLDOMNode::selectSingleNode doesn’t work because it must return the … Continue reading

Posted in Tips | Leave a comment

Boost Spirit V2: Parse C/C++ enum syntax with auto value generation

In C/C++, the following syntax automatically assign 0 to apple and 1 to orange. How to do this in Spirit? enum foo { apple, orange, }; You can use local variable and argument to make an incrementing counter. To parse … Continue reading

Posted in Tips | Leave a comment

Boost Spirit V2: identifier separated by a space

The following boost spirit grammar tries to parse the text like “int foo;”. template <typename Iterator> struct test_grammar : boost::spirit::qi::grammar<Iterator, boost::spirit::qi::space_type> { test_grammar() : test_grammar::base_type(start){ using boost::spirit::qi::alpha; using boost::spirit::qi::lexeme; identifier = +alpha; start = identifier >> identifier >> ‘;’; } … Continue reading

Posted in Tips | Leave a comment