Skip to content

Commit

Permalink
Prevent JPEG loader from trashing the next image in the stream
Browse files Browse the repository at this point in the history
  • Loading branch information
er258 committed Feb 1, 2005
1 parent d91fa34 commit 8c2d463
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 14 deletions.
17 changes: 10 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ HEADERS=cvd/arch.h cvd/version.h
################################################################################
#
# Test programs
PROGS=progs/se3_exp progs/se3_ln progs/se3_pre_mul progs/se3_post_mul progs/img_play progs/img_play_bw
PROGS=progs/se3_exp progs/se3_ln progs/se3_pre_mul progs/se3_post_mul progs/img_play progs/img_play_bw progs/img_stream_play

TEST_all= test/test_images.test
TEST_Linux= test/v4l2buffer.test
Expand Down Expand Up @@ -210,22 +210,25 @@ configuration: cvd/arch.h

progs: libcvd.a $(PROGS)

progs/se3_exp: progs/se3_exp.o
progs/se3_exp: libcvd.a progs/se3_exp.o
$(CXX) $^ -o $@ $(OFLAGS) -L. -lcvd

progs/se3_ln: progs/se3_ln.o
progs/se3_ln: libcvd.a progs/se3_ln.o
$(CXX) $^ -o $@ $(OFLAGS) -L. -lcvd

progs/se3_pre_mul: progs/se3_pre_mul.o
progs/se3_pre_mul: libcvd.a progs/se3_pre_mul.o
$(CXX) $^ -o $@ $(OFLAGS) -L. -lcvd

progs/se3_post_mul: progs/se3_post_mul.o
progs/se3_post_mul: libcvd.a progs/se3_post_mul.o
$(CXX) $^ -o $@ $(OFLAGS) -L. -lcvd

progs/img_play: progs/img_play.o
progs/img_stream_play: libcvd.a progs/img_stream_play.o
$(CXX) $^ -o $@ $(OFLAGS) -L. -lcvd $(TESTLIB)

progs/img_play: libcvd.a progs/img_play.o
$(CXX) $^ -o $@ $(OFLAGS) -L. -lcvd $(TESTLIB)

progs/img_play_bw: progs/img_play_bw.o
progs/img_play_bw: libcvd.a progs/img_play_bw.o
$(CXX) $^ -o $@ $(OFLAGS) -L. -lcvd $(TESTLIB)
clean:
rm -f libcvd.a
Expand Down
2 changes: 1 addition & 1 deletion TODO
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ In no particular order

More helper functions for diskbuffer
JPEG saving
Prevent JPEG loader from trashing the next one in the stream

Mpeg buffer
Colourspace buffer
Expand All @@ -21,3 +20,4 @@ In no particular order

Done
Working v4l2buffer for 2.6
Prevent JPEG loader from trashing the next one in the stream
51 changes: 45 additions & 6 deletions pnm_src/jpeg.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "cvd/image_io.h"
using namespace std;
#include <iostream>
#include <iomanip>
#include <setjmp.h>

namespace CVD
Expand All @@ -16,7 +17,7 @@ struct jpeg_istream_src: public jpeg_source_mgr
istream* i;
bool eof;
static const int bufsize=8192;
JOCTET buf[bufsize];
JOCTET buf[bufsize+2];

//Constructor
static void create(j_decompress_ptr p, istream* is)
Expand Down Expand Up @@ -50,7 +51,10 @@ struct jpeg_istream_src: public jpeg_source_mgr

static boolean s_fill_input_buffer(j_decompress_ptr p)
{

int n=0;
jpeg_istream_src* me = (jpeg_istream_src*)p->src;
me->next_input_byte = me->buf;

if(me->eof)
{
Expand All @@ -61,12 +65,47 @@ struct jpeg_istream_src: public jpeg_source_mgr
return true;
}

//FIXME fix so that this never reads too many bytes (ie look for EOI marker)
//this will allow multiple images to reside in one stream
int c;
for(n=0; n < bufsize; n++)
{
//Get a byte...
c = me->i->get();

me->i->read((char*)(me->buf), bufsize);
me->bytes_in_buffer = me->i->gcount();
me->next_input_byte = me->buf;

//Check for EOF...
if(c == EOF)
{
me->eof = 1;
break;
}

//Store the byte...
me->buf[n] = c;

//ooooh! a marker!
if(c == 0xff)
{
c = me->i->get();
if(c == EOF)
{
me->eof = 1;
break;
}


me->buf[++n] = c;

if(c == JPEG_EOI)
{
me->eof = 1;
break;
}
}
}

//me->i->read((char*)(me->buf), bufsize);
//me->bytes_in_buffer = me->i->gcount();
me->bytes_in_buffer = n;

if(me->i->eof())
me->eof = 1;
Expand Down

0 comments on commit 8c2d463

Please sign in to comment.