{
pos++;
pattern = (pattern << 8) | data[pos];
- if (pattern==DEMUXER_PIC_HEAD) count++;
+ if (pattern==DEMUXER_PIC_HEAD)
+ {
+ count++;
+ }
+ // Now also search for EXT_START_CODE headers and if it's a Picture Coding Extension,
+ // and the picture structure is set to interlaced - bottom field (2), reverse the frame count by 1
+ else if (pattern == 0x000001b5) // EXT_START_CODE
+ {
+ u1 extbyte1 = data[pos+1];
+
+ if ((extbyte1 & 0xF0) == 0x80) // First 4 bits are 0001
+ {
+ u1 extbyte3 = data[pos+3];
+ u1 picstruct = extbyte3 & 0x3;
+ if (picstruct == 2)
+ {
+ count--;
+ }
+ }
+ }
}
return count;
}