--- vdr-1.3.21-orig/recorder.c 2005-01-16 14:53:17.000000000 +0200 +++ vdr-1.3.21/recorder.c 2005-04-22 03:33:37.000000000 +0300 @@ -29,4 +31,6 @@ uchar pictureType; int fileSize; +char *baseFileName; +cMarks myMarks; int recordFile; bool active; @@ -60,4 +65,6 @@ esyslog("ERROR: can't allocate index"); // let's continue without index, so we'll at least have the recording +myMarks.Load(FileName); +baseFileName = strdup(FileName); } @@ -66,4 +73,5 @@ active = false; Cancel(3); +free(baseFileName); delete index; delete fileName; @@ -94,6 +104,30 @@ } +#if 1 +static int ScanVP(const uchar *Data, int Count, int Offset) +{ + int Length = Count; //GetPacketLength(Data, Count, Offset); + if (Length > 0) { + if (Length >= 8) { + int i = Offset + 8; // the minimum length of the video packet header + i += Data[i] + 1; // possible additional header bytes + for (; i < Offset + Length - 5; i++) { + if (Data[i] == 0 && Data[i + 1] == 0 && Data[i + 2] == 1) { + switch (Data[i + 3]) { + case 0xb3: + //fprintf(stderr,"A=%x\n", Data[i + 7] >> 4); fflush(stderr); + return Data[i + 7] >> 4; + } + } + } + } + } + return -1; +} +#endif + void cFileWriter::Action(void) { +int last_asp = -1, mark_set = 0; time_t t = time(NULL); active = true; @@ -105,7 +139,24 @@ if (!active && pictureType == I_FRAME) // finish the recording before the next 'I' frame break; +int asp = ScanVP(p, Count, 0); +if(last_asp == -1) + last_asp = asp; +else if(asp != -1 && asp != last_asp) { + fprintf(stderr,"ASPECT CHANGED %x -> %x\n", last_asp, asp);fflush(stderr); + last_asp = asp; + mark_set = !mark_set; +} + if (NextFile()) { - if (index && pictureType != NO_PICTURE) + if (index && pictureType != NO_PICTURE) { index->Write(pictureType, fileName->Number(), fileSize); +if(mark_set && pictureType == I_FRAME) { + myMarks.Load(baseFileName); + myMarks.Add(index->Last()); + myMarks.Save(); + mark_set = 0; + fprintf(stderr," index %d\n", index->Last());fflush(stderr); + } +} if (safe_write(recordFile, p, Count) < 0) { LOG_ERROR_STR(fileName->Name());