Am Montag, 22. Oktober 2007 17:25 schrieb Michael Riepe:
> Actually, you can pass the std::vector by value. Pointers have the
> disadvantage that they may be NULL.
And what about the regular NULL-pointer when reading from a MPEG-PS?
OK,... I guess when the returned vector is empty, nothing will happen and we
can skip the test for NULL... so we just have to make sure that instead as
default an empty vector<int> is returned from mpg::getbookmarks()!
> Maybe we can print a message to the status area at the bottom of the
> window instead (the one that also shows the "tooltips"). Should be as
> easy as
>
> statusBar()->message(QString("what was I going to say?"));
>
> And it's less disruptive than a modal dialog.
Yes, that would be enough,... we just need any response to show that something
was going on and this function is not broken! But your suggested
statusBar()-call is not working... :-(
So (just for the moment) I replaced it by a simple fprintf in the attached
patch file... ;-)
ciao
Ralph
diff -Naur svn/src/dvbcut.cpp r92-list/src/dvbcut.cpp
--- svn/src/dvbcut.cpp 2007-10-22 12:05:55.000000000 +0200
+++ r92-list/src/dvbcut.cpp 2007-10-22 18:50:48.000000000 +0200
@@ -657,16 +657,25 @@
void dvbcut::editSuggest()
{
- int pic = 0;
- while ((pic = mpg->nextaspectdiscontinuity(pic)) >= 0)
+ int pic = 0, found=0;
+ while ((pic = mpg->nextaspectdiscontinuity(pic)) >= 0) {
addEventListItem(pic, EventListItem::bookmark);
+ found++;
+ }
+ if(!found)
+ fprintf(stderr,"No aspect ratio changes detected!\n");
}
void dvbcut::editImport()
{
- int *bookmark = mpg->getbookmarks();
- while(bookmark && *bookmark)
- addEventListItem(*bookmark++, EventListItem::bookmark);
+ int found=0;
+ std::vector<int> bookmarks = mpg->getbookmarks();
+ for (std::vector<int>::iterator b = bookmarks.begin(); b != bookmarks.end(); ++b) {
+ addEventListItem(*b, EventListItem::bookmark);
+ found++;
+ }
+ if(!found)
+ fprintf(stderr,"No valid bookmarks available/found!\n");
}
void dvbcut::viewDifference()
diff -Naur svn/src/mpgfile.h r92-list/src/mpgfile.h
--- svn/src/mpgfile.h 2007-10-22 12:05:55.000000000 +0200
+++ r92-list/src/mpgfile.h 2007-10-22 18:28:50.000000000 +0200
@@ -65,9 +65,10 @@
{
return false;
}
- virtual int *getbookmarks()
+ virtual std::vector<int> getbookmarks()
{
- return NULL;
+ std::vector<int> pic_bookmarks;
+ return pic_bookmarks;
}
int getinitialoffset() const
diff -Naur svn/src/tsfile.cpp r92-list/src/tsfile.cpp
--- svn/src/tsfile.cpp 2007-10-22 12:05:55.000000000 +0200
+++ r92-list/src/tsfile.cpp 2007-10-22 16:05:58.000000000 +0200
@@ -258,8 +258,7 @@
unsigned int frequency, symbolrate, modulation;
int boff=len, off=0, type=0, hlen=0, verbose=0;
- // initialize bookmark array!
- byte_bookmarks[0] = 0;
+ // this routine stores bookmarks as byte positions!
bytes = true;
// just in case there's a corrupted TS packet at the beginning
@@ -324,22 +323,20 @@
// OK,... we identified a receiver model!
int bnum = 0;
//if(len>=hlen) // discard ALL (slightly) to small headers...? No, only require enough space for the bookmarks...
- if(len>=boff+4*MAX_BOOKMARKS) {
+ if(len>=boff+4*TF_MAX_BOOKMARKS) {
// Seems to be a Topfield TF4000PVR/TF5xxxPVR TS-header with 576/3760bytes total length
// and up to 64 bookmarks (BUT can be shorter/corrupted due to COPY/CUT-procedure on reveiver)
- unsigned int bookmark;
- do {
- bookmark = (header[boff]<<24)|(header[boff+1]<<16)|(header[boff+2]<<8)|header[boff+3];
+ dvbcut_off_t bookmark;
+ while ((bookmark=(header[boff]<<24)|(header[boff+1]<<16)|(header[boff+2]<<8)|header[boff+3])
+ && bnum<TF_MAX_BOOKMARKS) {
// bookmark is stored in 128 resp. 94kbyte units
- byte_bookmarks[bnum] = bookmark*unit;
- if(verbose && bookmark) fprintf(stderr,"BOOKMARK[%d] = %lld\n",bnum,byte_bookmarks[bnum]);
+ bookmark*=unit;
+ if(verbose) fprintf(stderr,"BOOKMARK[%d] = %lld\n",bnum,bookmark);
+ // fill bookmark vector with byte positions
+ byte_bookmarks.push_back(bookmark);
bnum++;
boff+=4;
}
- while(bookmark && bnum<MAX_BOOKMARKS);
- // add a terminating zero marker!
- if(bnum==MAX_BOOKMARKS) byte_bookmarks[bnum] = 0;
- else bnum--;
} else // receiver model identified but header to short!
fprintf(stderr,"Header probabely corrupted (%dbytes to short), discarding bookmarks!\n",hlen-len);
diff -Naur svn/src/tsfile.h r92-list/src/tsfile.h
--- svn/src/tsfile.h 2007-10-22 12:05:55.000000000 +0200
+++ r92-list/src/tsfile.h 2007-10-22 18:28:28.000000000 +0200
@@ -36,7 +36,7 @@
#define TF5010PVR_POS (1404)
#define TF4000PVR_LEN (3*TSPACKETSIZE)
#define TF4000PVR_POS (216)
-#define MAX_BOOKMARKS (64)
+#define TF_MAX_BOOKMARKS (64)
/**
@author Sven Over
@@ -103,12 +103,9 @@
size_t get_si_table(uint8_t*, size_t, size_t&, int, int);
int isTOPFIELD(const uint8_t*, int);
- // indicates type of read bookmarks (frame numbers or byte positions)
- bool bytes;
- // to store the bookmarks in byte positions (terminated by a zero-bookmark)
- dvbcut_off_t byte_bookmarks[MAX_BOOKMARKS+1];
- // to store the bookmarks in frame numbers (terminated by a zero-bookmark)
- int pic_bookmarks[MAX_BOOKMARKS+1];
+ bool bytes; // indicates type of read bookmarks
+ std::vector<dvbcut_off_t> byte_bookmarks; // to store the bookmarks in byte positions
+ std::vector<int> pic_bookmarks; // to store the bookmarks in frame numbers
public:
tsfile(inbuffer &b, int initial_offset);
@@ -122,13 +119,13 @@
virtual bool istransportstream() {
return true;
}
- virtual int *getbookmarks() {
+ virtual std::vector<int> getbookmarks() {
if(bytes) {
- int pic, nbp=0,nbb=0;
- while(byte_bookmarks[nbb])
- if((pic = getpictureatposition(byte_bookmarks[nbb++])) >= 0)
- pic_bookmarks[nbp++] = pic;
- pic_bookmarks[nbp] = 0;
+ // convert byte positions to frame numbers if not already done/stored
+ int pic;
+ for (std::vector<dvbcut_off_t>::iterator b = byte_bookmarks.begin(); b != byte_bookmarks.end(); ++b)
+ if((pic = getpictureatposition(*b)) >= 0)
+ pic_bookmarks.push_back(pic);
bytes = false;
}
return pic_bookmarks;
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
DVBCUT-user mailing list
DVBCUT-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dvbcut-user