[XviD-devel] trying to introduce resync markers
Angela Belda
anbelor at doctor.upv.es
Thu May 12 17:24:52 CEST 2005
Hi Everybody!
I am new here, in this mail list, but I have been working a while with
xvid. I am interested in video streaming aplications and Java and I have
created some JNI modules to acces the xvid encoder/decoder from Java
code. Using Java Media Framework I can encode and decode live content
using native xvid and transmit it over RTP.
Now I wanted to add the possibility to include resynchronization markers
in a xvid encoded stream, because the decoder already supports this
option and it didn't seem very difficult. I create the markers with the
following method:
void write_video_packet_header(Bitstream * const bs,
const MBParam * pParam,
const FRAMEINFO * const frame,
int mbnum){
int mbnum_bits = log2bin(pParam->mb_width * pParam->mb_height - 1);
uint32_t nbitsresyncmarker;
int addbits=0;
if (frame->coding_type != I_VOP)
addbits = frame->fcode -1;
if (frame->coding_type == B_VOP)
addbits = max(frame->fcode, frame->bcode)-1;
BitstreamPadAlways(bs);
nbitsresyncmarker = NUMBITS_VP_RESYNC_MARKER + addbits;
BitstreamPutBits(bs, RESYNC_MARKER, nbitsresyncmarker);
BitstreamPutBits(bs, mbnum, mbnum_bits);
BitstreamPutBits(bs, frame->quant, 5);
BitstreamPutBit(bs, 0); /* hec */
}
Then I modify the methods FrameCodeI and FrameCodeP to reset MV
prediction on boundaries. With I Frames I introduce a resync marker when
the number of bits encoded reaches a specified value, as specified in
the standard, but that seems not to possible with P frames, because I
need to know where to reset the MV prediction before encoding. I have
modified the method MotionEstimation to reset MV prediction
periodically, each fixed number of macroblocks and it seems to work
fine, but I am not sure what to do to introduce the resync markers as
specified in the standard. Any ideas?
The next step is to detect this markers in Java and partitionate the
encoded frames before encapsulating over RTP. I had the idea to create a
new output parameter in the encoder. This new parameter would be an
array of bitstream positions where resync markers were introduced. The
other possibility would be to look for these resync markers direct in
Java, before packetizing, but if I cannot know a fixed minimum number of
bytes between resync markers I should look in the whole bitstrem,
shouldn't I?. Any suggestions?
Thanks in advance,
Ángela
More information about the XviD-devel
mailing list