Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…250c61c0-cc0d-0410-af45-d4f8fccfe43b
  • Loading branch information
jnmchlptt committed Jun 17, 2006
1 parent c9c069f commit bf80c1c
Show file tree
Hide file tree
Showing 15 changed files with 140 additions and 266 deletions.
12 changes: 11 additions & 1 deletion README
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
install from sources:

if problems with ./configure try make -f Makefile.cvs before
make -f Makefile.cvs
./configure --prefix=/usr
make
make install (as root)


k9copy can now copy dvd with bad sectors.
for a faster copy from a dvd with bad sectors : reduce the readahead for the drive :

as root: hdparm -a8 /dev/dvd
82 changes: 77 additions & 5 deletions libk9copy/k9dvdbackup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ uint32_t k9DVDBackup::copyMenu2(int _vts) {
k9Ifo kifo(&m_dvdread);
kifo.openIFO( _vts);
ifo_handle_t *hifo =kifo.getIFO();
m_ifo=hifo;
uint32_t msize=0;
if (_vts==0)
msize=hifo->vmgi_mat->vmg_last_sector -1 - 2* hifo->vmgi_mat->vmgi_last_sector;
Expand Down Expand Up @@ -659,6 +660,45 @@ void k9DVDBackup::playCell (int vts_num, k9Cell *_cell) {
dvdfile->close();
}

void k9DVDBackup::setDummyNavPack(uchar *buf,uint32_t _sector)
{
int8_t *ptr = (int8_t*)buf;
static uint8_t nav_pack1 [] =
{
/* pack header: SCR=0, mux rate=10080000bps, stuffing length=0 */
0, 0, 1, 0xba, 0x44, 0x00, 0x04, 0x00, 0x04, 0x01, 0x01, 0x89, 0xc3, 0xf8,
/* system header */
0, 0, 1, 0xbb, 0x00, 0x12,
/* contents of system header filled in at run time (18 bytes) */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* PES header for first private stream 2 packet */
0, 0, 1, 0xbf, 0x03, 0xd4
};
static uint8_t nav_pack2 [] =
{
/* PES header for second private stream 2 packet */
0, 0, 1, 0xbf, 0x03, 0xfa
};

memcpy (ptr, nav_pack1, sizeof (nav_pack1));
ptr += sizeof (nav_pack1);
memset (ptr, 0, DVD_VIDEO_LB_LEN/2 - sizeof (nav_pack1));
ptr = (int8_t*)buf + DVD_VIDEO_LB_LEN/2;
memcpy (ptr, nav_pack2, sizeof (nav_pack2));
ptr += sizeof (nav_pack2);
memset (ptr, 0, DVD_VIDEO_LB_LEN/2 - sizeof (nav_pack2));

dsi_t dsiPack;
pci_t pciPack;
navRead_DSI (&dsiPack, buf + DSI_START_BYTE);
k9Ifo::navRead_PCI (&pciPack, buf+0x2d);
dsiPack.dsi_gi.nv_pck_lbn=_sector;
dsiPack.dsi_gi.vobu_ea = 0;

navRead_DSI((dsi_t*)(buf + DSI_START_BYTE),(uchar*)&dsiPack);
pciPack.pci_gi.nv_pck_lbn =dsiPack.dsi_gi.nv_pck_lbn;
k9Ifo::navRead_PCI((pci_t*)(buf+0x2d),(uchar*)&pciPack);
}


void k9DVDBackup::setDummyPack(uchar *_buffer) {
Expand All @@ -677,16 +717,46 @@ void k9DVDBackup::setDummyPack(uchar *_buffer) {

}


uint32_t k9DVDBackup::findNextVobu(uint32_t _sector) {
k9Ifo ifo(&m_dvdread);
ifo.openIFO(currVTS);
m_ifo=ifo.getIFO();
vobu_admap_t * vobu_admap;
if (m_copyMenu)
vobu_admap = m_ifo->menu_vobu_admap;
else
vobu_admap = m_ifo->vts_vobu_admap;
uint32_t length = vobu_admap->last_byte + 1 - VOBU_ADMAP_SIZE;
for(uint32_t i = 0; i < length/sizeof(uint32_t); i++) {
if (vobu_admap->vobu_start_sectors[i]== _sector) {
uint32_t nextVobu=vobu_admap->vobu_start_sectors[i+1];
ifo.closeIFO();
return nextVobu;
}
}
ifo.closeIFO();
return 0;

}



uint32_t k9DVDBackup::copyVobu(k9DVDFile *_fileHandle,uint32_t _startSector,k9Vobu * _vobu) {
dsi_t dsi_pack;
k9Vobu * currVobu;

uint32_t nsectors, len;
uint32_t nsectors, len,nextVobu=0;
uchar *buf;
uint32_t sector=_startSector;
/* read nav pack */
buf=(uchar*) malloc(DVD_VIDEO_LB_LEN);
len = _fileHandle->readBlocks ( sector, 1, buf);
if (len==-1) {
setDummyNavPack(buf,sector);
nextVobu=findNextVobu(sector);
qDebug (QString("VOBU : %1 Read Error !!!! ==> %2").arg(sector).arg(nextVobu));
}
currVobu=_vobu;

mutex.lock();
Expand All @@ -712,6 +782,7 @@ uint32_t k9DVDBackup::copyVobu(k9DVDFile *_fileHandle,uint32_t _startSector,k9V
buf=(uchar*) realloc(buf,nsectors*DVD_VIDEO_LB_LEN);

uint32_t end=nsectors;
if (nextVobu !=0) end=nextVobu-1;

/* read VOBU */
for (uint32_t i=0;i< nsectors;i++) {
Expand All @@ -723,6 +794,7 @@ uint32_t k9DVDBackup::copyVobu(k9DVDFile *_fileHandle,uint32_t _startSector,k9V
break;
}
}

/* write VOBU */
for (uint32_t i=0;i<nsectors ;i++) {
vamps->addData(buf + (i*DVD_VIDEO_LB_LEN), DVD_VIDEO_LB_LEN);
Expand Down Expand Up @@ -891,7 +963,7 @@ void k9DVDBackup::updateMainIfo() {
updatePgci_ut(hifo);
update4Menu(hifo);

//mise à jour des startSectors
//mise jour des startSectors
k9TitleSet *TSp=NULL;
titleSets.sort();
for (uint iTS=0;iTS < titleSets.count();iTS++) {
Expand Down Expand Up @@ -977,7 +1049,7 @@ void k9DVDBackup::updatePgci_ut(ifo_handle_t *_hifo) {
}

void k9DVDBackup::update4Menu(ifo_handle_t *_hifo) {
// Mise à jour vtsm_c_adt pour le menu
// Mise jour vtsm_c_adt pour le menu
m_copyMenu=true; //indispensable pour remapvobu
c_adt_t *c_adt = _hifo->menu_c_adt;
uint32_t length;
Expand Down Expand Up @@ -1407,11 +1479,11 @@ void k9DVDBackup::updateVob(k9CellList *cellLst) {
pciPack.pci_gi.e_eltm.hour = pciPack.pci_gi.e_eltm.minute =pciPack.pci_gi.e_eltm.second=0;
dsiPack.dsi_gi.c_eltm.hour=dsiPack.dsi_gi.c_eltm.minute=dsiPack.dsi_gi.c_eltm.second=0;
}
// mise en place des donnees modifiï¿?s dans le buffer de sortie
// mise en place des donnees modifi�s dans le buffer de sortie
navRead_DSI((dsi_t*)(buffer + DSI_START_BYTE),(uchar*)&dsiPack);
pciPack.pci_gi.nv_pck_lbn =dsiPack.dsi_gi.nv_pck_lbn;
k9Ifo::navRead_PCI((pci_t*)(buffer+0x2d),(uchar*)&pciPack);
//mise ï¿?jour du fichier
//mise jour du fichier
fseek(file,pos,SEEK_SET);
fwrite(buffer,DVD_VIDEO_LB_LEN,1,file);
}
Expand Down
3 changes: 3 additions & 0 deletions libk9copy/k9dvdbackup.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public slots:
long currVTS;
k9TitleSet *currTS;
int currVOB;
ifo_handle_t *m_ifo;
k9Cell *currCell,*cellOut;//,*currCopyCell;
k9CellCopyList *m_cellCopyList;
uint32_t m_position,m_vmgSize;
Expand All @@ -100,6 +101,7 @@ public slots:
uint64_t argSize;
void prepareVTS(int VTS);
void playCell (int vts_num, k9Cell *_cell);
uint32_t findNextVobu(uint32_t _sector);
uint32_t copyVobu(k9DVDFile *_fileHandle,uint32_t _startSector,k9Vobu *_vobu);
void copyCell(int VTS, k9Cell *_cell,bool _empty);
// void copyAngleBlock(k9CellCopyList *_list,uint _num);
Expand All @@ -111,6 +113,7 @@ public slots:
void updatePgci_ut(ifo_handle_t *_hifo);
void update4Menu(ifo_handle_t *_hifo);
void setDummyPack(uchar *_buffer);
void setDummyNavPack(uchar *_buffer,uint32_t _sector);
uint32_t copyMenu (int _vts);
uint32_t copyMenu2(int _vts);
k9CellList vmgCells;
Expand Down
9 changes: 7 additions & 2 deletions libk9copy/k9dvdread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
//
#include "k9dvdread.h"


k9DVDRead::k9DVDRead(){
m_dvd=NULL;
files.setAutoDelete(true);
Expand Down Expand Up @@ -136,9 +137,13 @@ int k9DVDFile::readBytes(uchar *_buffer,uint32_t _size)
}

int k9DVDFile::readBlocks(uint32_t _sector,uint32_t _size,uchar*_buffer) {
if (m_file !=NULL)
return DVDReadBlocks(m_file,_sector,_size,_buffer);
if (m_file !=NULL) {
return DVDReadBlocks(m_file,_sector,_size,_buffer);
}
else
return -1;
}




2 changes: 2 additions & 0 deletions libk9copy/k9dvdread.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
/**
@author Jean-Michel PETIT <k9copy@free.fr>
*/

class k9DVDRead;

class k9DVDFile {
Expand Down Expand Up @@ -58,4 +59,5 @@ friend class k9DVDTitle;

};


#endif
13 changes: 10 additions & 3 deletions libk9copy/k9mp4enc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,13 @@ void k9MP4Enc::execute(k9DVDTitle *_title) {
bool error=false;
m_percent=0;
m_remain="--:--:--";
m_totalSize=(_title->getChapter(_title->getchapterCount()-1)->getendSector() - _title->getChapter(0)->getstartSector());

for (uint m_part =1 ; (m_part <=m_parts) && !error ;m_part++) {
uint32_t sec1=_title->getChapter(0)->getstartSector();
uint32_t sec2=_title->getChapter(_title->getchapterCount()-1)->getendSector();

uint32_t nbSectors= (_title->getChapter(_title->getchapterCount()-1)->getendSector() - _title->getChapter(0)->getstartSector()) / m_parts ;
uint32_t nbSectors= m_totalSize / m_parts ;

uint32_t startSector= nbSectors*(m_part-1);
uint32_t endSector= startSector+nbSectors;
Expand Down Expand Up @@ -84,9 +85,15 @@ void k9MP4Enc::execute(k9DVDTitle *_title) {
m_progress->setsize(m_size +i18n("mb") +" X " +QString::number(m_parts));
m_process=new KProcess();
m_process->setUseShell(true);
*m_process << "k9copy" << "--play" << "--startsector" << QString::number(startSector) << "--endsector" << QString::number(endSector) ;
*m_process << "k9copy" << "--play" << "--endsector" << QString::number(endSector) ;
*m_process << "--inject" << "/tmp/kde-jmp/inject";
*m_process << "--input" << "'"+m_device+"'";
*m_process << "--dvdtitle" << QString::number(_title->getnumTitle());
if (m_part==1)
*m_process << "--initstatus";
else
*m_process << "--continue";


for (uint i=0;i<_title->getaudioStreamCount();i++) {
if (_title->getaudioStream(i)->getselected()) {
Expand Down Expand Up @@ -259,7 +266,7 @@ void k9MP4Enc::getStderr(KProcess *proc, char *buffer, int buflen) {
QString tmp=m_stderr.mid(pos);
uint32_t totalBytes,totalSize;
sscanf(tmp.latin1(),"INFOPOS: %d %d",&totalBytes,&totalSize);
m_percent=(float)totalBytes / (float)totalSize;
m_percent=(float)totalBytes / (float)m_totalSize;


QTime time2(0,0);
Expand Down
1 change: 1 addition & 0 deletions libk9copy/k9mp4enc.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class k9MP4Enc : public QObject {
float m_percent;
QTimer *timer;
QString m_remain;
uint32_t m_totalSize;

Codec m_codec;
QStringList m_lstVideo,m_lstAudio,m_lstCodecs;
Expand Down
89 changes: 0 additions & 89 deletions src/MainDlg.ui.h

This file was deleted.

2 changes: 1 addition & 1 deletion src/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,7 @@ clean-metasources:
-rm -f menupreview.moc k9main.moc.cpp kcddrive.moc.cpp k9settings.moc k9copy.moc.cpp kviewmpeg2.moc.cpp k9prefdvd.moc k9prefmpeg4.moc k9prefmencoder.moc

#>+ 2
KDE_DIST=viewmpeg2.ui open_k9copy.desktop configDlg.ui prefMPEG4.ui k9mainw.ui k9copyui.rc hi16-app-k9copy.png k9mainw.h hi48-app-k9copy.png prefDVD.h prefDVD.ui hi32-app-k9copy.png prefMencoder.h configDlg.ui.h viewmpeg2.h Makefile.in prefMencoder.ui k9copy.desktop MainDlg.ui.h k9copy configDlg.h menupreview.cpp Makefile.am prefMPEG4.h menupreview.h
KDE_DIST=viewmpeg2.ui open_k9copy.desktop configDlg.ui prefMPEG4.ui k9mainw.ui k9copyui.rc hi16-app-k9copy.png k9mainw.h hi48-app-k9copy.png prefDVD.h prefDVD.ui hi32-app-k9copy.png prefMencoder.h viewmpeg2.h Makefile.in prefMencoder.ui k9copy.desktop configDlg.h k9copy menupreview.cpp Makefile.am prefMPEG4.h menupreview.h

#>+ 9
clean-ui:
Expand Down
4 changes: 1 addition & 3 deletions src/configDlg.ui
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,7 @@
<slot>bAddClick()</slot>
</connection>
</connections>
<includes>
<include location="local" impldecl="in implementation">configDlg.ui.h</include>
</includes>

<slots>
<slot>bRemoveClick()</slot>
<slot>bAddClick()</slot>
Expand Down
Loading

0 comments on commit bf80c1c

Please sign in to comment.