-rw-r--r-- | noncore/multimedia/camera/avi.c | 3 | ||||
-rw-r--r-- | noncore/multimedia/camera/mainwindow.cpp | 10 |
2 files changed, 9 insertions, 4 deletions
diff --git a/noncore/multimedia/camera/avi.c b/noncore/multimedia/camera/avi.c index 0c757c9..77aba33 100644 --- a/noncore/multimedia/camera/avi.c +++ b/noncore/multimedia/camera/avi.c | |||
@@ -103,41 +103,42 @@ void avi_end(int fd, int width, int height, int fps) | |||
103 | struct list_head lh4 = {"LIST", 0, "movi"}; | 103 | struct list_head lh4 = {"LIST", 0, "movi"}; |
104 | int i; | 104 | int i; |
105 | unsigned int offset = 4; | 105 | unsigned int offset = 4; |
106 | 106 | ||
107 | printf( "avi_end: nframes = %d, fps = %d\n", nframes, fps ); | 107 | printf( "avi_end: nframes = %d, fps = %d\n", nframes, fps ); |
108 | 108 | ||
109 | // write index | 109 | // write index |
110 | 110 | ||
111 | write(fd, &idx, sizeof(idx)); | 111 | write(fd, &idx, sizeof(idx)); |
112 | 112 | ||
113 | for ( i = 0; i < nframes; i++ ) | 113 | for ( i = 0; i < nframes; i++ ) |
114 | { | 114 | { |
115 | write(fd, &db, 4 ); // only need the 00db | 115 | write(fd, &db, 4 ); // only need the 00db |
116 | fprint_quartet( fd, 18 ); // ??? | 116 | fprint_quartet( fd, 18 ); // ??? |
117 | fprint_quartet( fd, offset ); | 117 | fprint_quartet( fd, offset ); |
118 | fprint_quartet( fd, sizes[i] ); | 118 | fprint_quartet( fd, sizes[i] ); |
119 | offset += sizes[i]; | 119 | offset += sizes[i] + 8; //+8 (for the additional header) |
120 | } | 120 | } |
121 | 121 | ||
122 | free( sizes ); | 122 | free( sizes ); |
123 | 123 | ||
124 | bzero( &ah, sizeof(ah) ); | 124 | bzero( &ah, sizeof(ah) ); |
125 | strcpy(ah.avih, "avih"); | 125 | strcpy(ah.avih, "avih"); |
126 | ah.time = 1000000 / fps; | 126 | ah.time = 1000000 / fps; |
127 | ah.maxbytespersec = 1000000.0*(totalsize/nframes)/ah.time; | 127 | ah.maxbytespersec = 1000000.0*(totalsize/nframes)/ah.time; |
128 | ah.nframes = nframes; | ||
128 | ah.numstreams = 1; | 129 | ah.numstreams = 1; |
129 | ah.flags = AVIF_HASINDEX; | 130 | ah.flags = AVIF_HASINDEX; |
130 | ah.width = width; | 131 | ah.width = width; |
131 | ah.height = height; | 132 | ah.height = height; |
132 | 133 | ||
133 | bzero(&sh, sizeof(sh)); | 134 | bzero(&sh, sizeof(sh)); |
134 | strcpy(sh.strh, "strh"); | 135 | strcpy(sh.strh, "strh"); |
135 | strcpy(sh.vids, "vids"); | 136 | strcpy(sh.vids, "vids"); |
136 | strcpy(sh.codec, "MJPG"); | 137 | strcpy(sh.codec, "MJPG"); |
137 | sh.scale = ah.time; | 138 | sh.scale = ah.time; |
138 | sh.rate = 1000000; | 139 | sh.rate = 1000000; |
139 | sh.length = nframes; | 140 | sh.length = nframes; |
140 | 141 | ||
141 | bzero(&fh, sizeof(fh)); | 142 | bzero(&fh, sizeof(fh)); |
142 | strcpy(fh.strf, "strf"); | 143 | strcpy(fh.strf, "strf"); |
143 | fh.width = width; | 144 | fh.width = width; |
diff --git a/noncore/multimedia/camera/mainwindow.cpp b/noncore/multimedia/camera/mainwindow.cpp index e27a50e..7e60e16 100644 --- a/noncore/multimedia/camera/mainwindow.cpp +++ b/noncore/multimedia/camera/mainwindow.cpp | |||
@@ -483,34 +483,38 @@ void CameraMainWindow::postProcessVideo( const QString& infile, const QString& o | |||
483 | label->setText( QString().sprintf( "Post processing frame %d / %d", i+1, _videopics ) ); | 483 | label->setText( QString().sprintf( "Post processing frame %d / %d", i+1, _videopics ) ); |
484 | bar->setProgress( i ); | 484 | bar->setProgress( i ); |
485 | bar->repaint(); | 485 | bar->repaint(); |
486 | qApp->processEvents(); | 486 | qApp->processEvents(); |
487 | // </gui> | 487 | // </gui> |
488 | 488 | ||
489 | int read = ::read( infd, inbuffer, framesize ); | 489 | int read = ::read( infd, inbuffer, framesize ); |
490 | odebug << "read " << read << " bytes" << oendl; | 490 | odebug << "read " << read << " bytes" << oendl; |
491 | bufferToImage( captureX, captureY, inbuffer, &image ); | 491 | bufferToImage( captureX, captureY, inbuffer, &image ); |
492 | 492 | ||
493 | QPixmap p; | 493 | QPixmap p; |
494 | p.convertFromImage( image ); | 494 | p.convertFromImage( image ); |
495 | preview->setPixmap( p ); | 495 | preview->setPixmap( p ); |
496 | preview->repaint(); | 496 | preview->repaint(); |
497 | qApp->processEvents(); | 497 | qApp->processEvents(); |
498 | 498 | ||
499 | #ifndef QT_NO_DEBUG | ||
500 | QString tmpfilename; | ||
501 | tmpfilename.sprintf( "/tmp/test/%04d.jpg", i ); | ||
502 | #else | ||
499 | QString tmpfilename( "/tmp/tempfile" ); | 503 | QString tmpfilename( "/tmp/tempfile" ); |
500 | //tmpfilename.sprintf( "/tmp/test/%d.jpg", i ); | 504 | #endif |
501 | 505 | ||
502 | imageToFile( &image, tmpfilename, "JPEG", quality ); | 506 | imageToFile( &image, tmpfilename, "JPEG", quality ); |
503 | 507 | ||
504 | QFile framefile( tmpfilename ); | 508 | QFile framefile( tmpfilename ); |
505 | if ( !framefile.open( IO_ReadOnly ) ) | 509 | if ( !framefile.open( IO_ReadOnly ) ) |
506 | { | 510 | { |
507 | oerr << "can't process file: %s" << strerror(errno) << oendl; | 511 | oerr << "can't process file: %s" << strerror(errno) << oendl; |
508 | return; // TODO: clean up temp ressources | 512 | return; // TODO: clean up temp ressources |
509 | } | 513 | } |
510 | 514 | ||
511 | int filesize = framefile.size(); | 515 | int filesize = framefile.size(); |
512 | odebug << "filesize for frame " << i << " = " << filesize << oendl; | 516 | odebug << "filesize for frame " << i << " = " << filesize << oendl; |
513 | 517 | ||
514 | unsigned char* tempbuffer = new unsigned char[ filesize ]; | 518 | unsigned char* tempbuffer = new unsigned char[ filesize ]; |
515 | framefile.readBlock( (char*) tempbuffer, filesize ); | 519 | framefile.readBlock( (char*) tempbuffer, filesize ); |
516 | avi_add( outfd, tempbuffer, filesize ); | 520 | avi_add( outfd, tempbuffer, filesize ); |
@@ -529,23 +533,23 @@ void CameraMainWindow::postProcessVideo( const QString& infile, const QString& o | |||
529 | 533 | ||
530 | 534 | ||
531 | void CameraMainWindow::updateCaption() | 535 | void CameraMainWindow::updateCaption() |
532 | { | 536 | { |
533 | if ( !_capturing ) | 537 | if ( !_capturing ) |
534 | setCaption( QString().sprintf( "Opie-Camera: %dx%d %s q%d z%d (%s)", captureX, captureY, (const char*) captureFormat.lower(), quality, zoom, (const char*) flip ) ); | 538 | setCaption( QString().sprintf( "Opie-Camera: %dx%d %s q%d z%d (%s)", captureX, captureY, (const char*) captureFormat.lower(), quality, zoom, (const char*) flip ) ); |
535 | else | 539 | else |
536 | setCaption( "Opie-Camera: => CAPTURING <=" ); | 540 | setCaption( "Opie-Camera: => CAPTURING <=" ); |
537 | } | 541 | } |
538 | 542 | ||
539 | 543 | ||
540 | #ifndef QT_NO_DEBUG | 544 | #ifndef QT_NO_DEBUG |
541 | void CameraMainWindow::doSomething() | 545 | void CameraMainWindow::doSomething() |
542 | { | 546 | { |
543 | captureX = 240; | 547 | captureX = 240; |
544 | captureY = 320; | 548 | captureY = 320; |
545 | _videopics = 176; | 549 | _videopics = 50; |
546 | _framerate = 5; | 550 | _framerate = 5; |
547 | postProcessVideo( "/var/compile/opie/noncore/multimedia/camera/capture-320x240.dat", | 551 | postProcessVideo( "/var/compile/opie/noncore/multimedia/camera/capture.dat", |
548 | "/tmp/output.avi" ); | 552 | "/tmp/output.avi" ); |
549 | } | 553 | } |
550 | #endif | 554 | #endif |
551 | 555 | ||