[MPlayer-dev-eng] [PATCH] Allow Elphel cameras to work
Reimar Döffinger
Reimar.Doeffinger at stud.uni-karlsruhe.de
Tue Sep 4 15:07:06 CEST 2007
Hello,
[...]
> -#define MAX_RTP_FRAME_SIZE 50000
> +#define MAX_RTP_FRAME_SIZE 4194304
> // >= the largest conceivable frame composed from one or more RTP packets
>
> +unsigned long rtp_frame_size = 65536;
Do not use long, it is architecture dependant. And just unsigned
(actually even int) is plenty enough, we will never (well, at least not
thinking of the reasonable future...) allow even something
close to 2GB per frame.
> static void afterReading(void* clientData, unsigned frameSize,
> - unsigned /*numTruncatedBytes*/,
> + unsigned truncSize,
> struct timeval presentationTime,
> unsigned /*durationInMicroseconds*/) {
> - int headersize = 0;
Please leave this line unchanged and put the declaration of size on a
new one.
> - if (frameSize >= MAX_RTP_FRAME_SIZE) {
> - fprintf(stderr, "Saw an input frame too large (>=%d). Increase MAX_RTP_FRAME_SIZE in \"demux_rtp.cpp\".\n",
> - MAX_RTP_FRAME_SIZE);
> - }
> + int headersize = 0, size = frameSize + truncSize;
> + size += size / 2;
Maybe check if any of these need overflow checks for security reasons (I
don't know which of these are variables with unchecked stream data).
> + if (size > rtp_frame_size) {
> + int i;
> + int j = size - 1;
> + for (i = 0; j >>= 1; i++);
av_log2 maybe? Though I don't know why it is even necessary to make
rtp_frame_size a power of 2.
> + rtp_frame_size = 1 << (i + 1);
> + if (rtp_frame_size > MAX_RTP_FRAME_SIZE) {
> + fprintf(stderr, "Saw an input frame too large (>=%d). Increase MAX_RTP_FRAME_SIZE in \"demux_rtp.cpp\".\n",
> + MAX_RTP_FRAME_SIZE);
> + rtp_frame_size = MAX_RTP_FRAME_SIZE;
Reindation cosmetics, also it changes >= to > in the if, but the message
still says >=...
Greetings,
Reimar Döffinger
More information about the MPlayer-dev-eng
mailing list