[FFmpeg-devel] add MJPEG support into RTP output

Martin Storsjö martin
Thu Apr 8 17:35:38 CEST 2010


On Thu, 8 Apr 2010, Nash Tsai wrote:

> I was wrong, the code was only handling little endian case, but the
> JPEGHdr struct doesn't need to worry about endian-ness as the handling
> of the network byte order should be taken before sending it off to the
> network, I may write it as following:

The field placement actually seems to be constant across some 
architectures in this case, but that cannot be relied upon. If you 
would have had bitfields with a size less than a byte, they would have 
been laid out differently on different architectures.

> if (htonl(offset) != offset)
>    jpghdr.off = htonl(offset) >> 8; /* we only interested in least
> significant 3 octets here */
> else
>    jpghdr.off = offset;

This is just horribly obfuscated. As far as I'm concerned, any patch doing 
things this way is rejected.

Just declare a uint8_t hdr[8] and write each field manually into the 
correct place of the buffer. For writing the offset you can use e.g.:

AV_WB24(&hdr[1], offset);

That's simple, clear and doesn't have any lurking portability issues.

// Martin



More information about the ffmpeg-devel mailing list