From 0d3a4b3c79f410ea543ebebedeacf81d65a0036a Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Sat, 10 Sep 2005 16:42:04 +0000 Subject: [PATCH] Widescreen version 2... --- command.cc | 12 ++++---- playervideo.cc | 77 ++++++++++++++++++++++++++++++++++++-------------- playervideo.h | 3 ++ video.cc | 27 +++++++++++++++--- video.h | 38 ++++++++++++++++--------- voptions.cc | 17 +++++++---- vvideolive.cc | 1 + vvideorec.cc | 15 ++++++++++ 8 files changed, 139 insertions(+), 51 deletions(-) diff --git a/command.cc b/command.cc index bc00eb8..26932f6 100644 --- a/command.cc +++ b/command.cc @@ -385,23 +385,21 @@ void Command::doJustConnected(VConnect* vconnect) { if (!strcasecmp(aspect, "16:9")) { - logger->log("Command", Log::INFO, "Switching to TV aspect 16:9"); - video->setAspectRatio(Video::ASPECT16X9); + logger->log("Command", Log::INFO, "/// Switching to TV aspect 16:9"); + video->setTVsize(Video::ASPECT16X9); } else { - logger->log("Command", Log::INFO, "Switching to TV aspect 4:3"); - video->setAspectRatio(Video::ASPECT4X3); + logger->log("Command", Log::INFO, "/// Switching to TV aspect 4:3"); + video->setTVsize(Video::ASPECT4X3); } } else { logger->log("Command", Log::INFO, "Config TV/Aspect type not found, going 4:3"); - video->setAspectRatio(Video::ASPECT4X3); + video->setTVsize(Video::ASPECT4X3); } - video->reinit(); - // config done viewman->removeView(vi); diff --git a/playervideo.cc b/playervideo.cc index aadf76e..999e8d0 100644 --- a/playervideo.cc +++ b/playervideo.cc @@ -216,15 +216,26 @@ void PlayerVideo::stop() playing = 0; paused = 0; + Log* templog = Log::getInstance(); + templog->log("PlayerVideo", Log::DEBUG, "Temp 1"); threadStop(); + templog->log("PlayerVideo", Log::DEBUG, "Temp 2"); video->stop(); + templog->log("PlayerVideo", Log::DEBUG, "Temp 3"); video->blank(); + templog->log("PlayerVideo", Log::DEBUG, "Temp 4"); audio->stop(); + templog->log("PlayerVideo", Log::DEBUG, "Temp 5"); audio->unPause(); + templog->log("PlayerVideo", Log::DEBUG, "Temp 6"); vfeed.stop(); + templog->log("PlayerVideo", Log::DEBUG, "Temp 7"); afeed.stop(); + templog->log("PlayerVideo", Log::DEBUG, "Temp 8"); video->reset(); + templog->log("PlayerVideo", Log::DEBUG, "Temp 9"); demuxer.reset(); + templog->log("PlayerVideo", Log::DEBUG, "Temp 10"); feedPosition = 0; } @@ -254,7 +265,6 @@ void PlayerVideo::togglePause() #ifdef DEV void PlayerVideo::test() { - Log::getInstance()->log("Player", Log::DEBUG, "PLAYER TEST"); /* @@ -272,13 +282,41 @@ void PlayerVideo::test() printf("A = %i\n", a); */ + + Log::getInstance()->log("Player", Log::DEBUG, "PLAYER TEST 1 4X3"); + video->setAspectRatio(Video::ASPECT4X3); } void PlayerVideo::test2() { - Log::getInstance()->log("Player", Log::DEBUG, "PLAYER TEST"); + Log::getInstance()->log("Player", Log::DEBUG, "PLAYER TEST 2 16X9"); + video->setAspectRatio(Video::ASPECT16X9); +} + +void PlayerVideo::test3() +{ + Log::getInstance()->log("Player", Log::DEBUG, "PLAYER TEST 3 NORMAL"); + video->setMode(Video::NORMAL); +} + +void PlayerVideo::test4() +{ + Log::getInstance()->log("Player", Log::DEBUG, "PLAYER TEST 4 LETTERBOX"); + video->setMode(Video::LETTERBOX); +} + +void PlayerVideo::test5() +{ + Log::getInstance()->log("Player", Log::DEBUG, "PLAYER TEST 5 REINIT"); + + video->stop(); +// video->reset(); + vfeed.stop(); +// video->reinit(); + vfeed.start(); + video->play(); + video->sync(); -// video->test2(); } #endif @@ -494,26 +532,23 @@ void PlayerVideo::call(void* caller) { Log* temp = Log::getInstance(); temp->log("Player", Log::DEBUG, "Callback from demuxer"); - if (video->getAspectRatio() == Video::ASPECT16X9) - { - temp->log("Player", Log::DEBUG, "TV is 16:9, so will try to do a switch"); - int dxCurrentAspect = demuxer.getAspectRatio(); - if (dxCurrentAspect == Demuxer::ASPECT_4_3) - { - temp->log("Player", Log::DEBUG, "Demuxer said video is 4:3 aspect, switching TV"); - video->setMode(Video::LETTERBOX); // swap these lines over - } - else if (dxCurrentAspect == Demuxer::ASPECT_16_9) - { - temp->log("Player", Log::DEBUG, "Demuxer said video is 16:9 aspect, switching TV"); - video->setMode(Video::NORMAL); // if these are the wrong way around - } - else - { - temp->log("Player", Log::DEBUG, "Demuxer said video is something else... ignoring"); - } + int dxCurrentAspect = demuxer.getAspectRatio(); + if (dxCurrentAspect == Demuxer::ASPECT_4_3) + { + temp->log("Player", Log::DEBUG, "Demuxer said video is 4:3 aspect, switching TV"); + video->setAspectRatio(Video::ASPECT4X3); + } + else if (dxCurrentAspect == Demuxer::ASPECT_16_9) + { + temp->log("Player", Log::DEBUG, "Demuxer said video is 16:9 aspect, switching TV"); + video->setAspectRatio(Video::ASPECT16X9); } + else + { + temp->log("Player", Log::DEBUG, "Demuxer said video is something else... ignoring"); + } + } else { diff --git a/playervideo.h b/playervideo.h index 28963f9..6cb0f5f 100644 --- a/playervideo.h +++ b/playervideo.h @@ -59,6 +59,9 @@ class PlayerVideo : public Player #ifdef DEV void test(); void test2(); + void test3(); + void test4(); + void test5(); #endif void threadMethod(); diff --git a/video.cc b/video.cc index 32d0fa9..acb2161 100644 --- a/video.cc +++ b/video.cc @@ -34,6 +34,7 @@ Video::Video() connection = 0; aspectRatio = 0; mode = 0; + tvsize = 0; screenWidth = 0; screenHeight = 0; @@ -58,26 +59,41 @@ int Video::init(UCHAR tformat) if (!setFormat(tformat)) { shutdown(); return 0; } if (!setConnection(COMPOSITERGB)) { shutdown(); return 0; } - if (!setMode(NORMAL)) { shutdown(); return 0; } if (!setAspectRatio(ASPECT4X3)) { shutdown(); return 0; } + if (!setMode(NORMAL)) { shutdown(); return 0; } if (!setSource()) { shutdown(); return 0; } if (!attachFrameBuffer()) { shutdown(); return 0; } + setTVsize(ASPECT4X3); + stop(); return 1; } -int Video::reinit() +int Video::setTVsize(UCHAR ttvsize) { + tvsize = ttvsize; + + // Override the aspect ratio usage, temporarily use to set the video chip mode + if (!setAspectRatio(tvsize)) { shutdown(); return 0; } close(fdVideo); if ((fdVideo = open("/dev/vdec_dev", O_WRONLY)) < 0) return 0; if (!setSource()) { shutdown(); return 0; } if (!attachFrameBuffer()) { shutdown(); return 0; } + // Reopening the fd causes the scart aspect line to go back to 4:3 + // Set this again to the same as the tv screen size + if (!setAspectRatio(tvsize)) { shutdown(); return 0; } + return 1; } +int Video::setDefaultAspect() +{ + return setAspectRatio(tvsize); +} + int Video::shutdown() { if (!initted) return 0; @@ -141,6 +157,7 @@ int Video::setAspectRatio(UCHAR taspectRatio) aspectRatio = taspectRatio; if (ioctl(fdVideo, AV_SET_VID_RATIO, aspectRatio) != 0) return 0; +// if (!setMode(mode)) return 0; return 1; } @@ -344,7 +361,9 @@ UINT Video::getScreenHeight() return screenHeight; } -UCHAR Video::getAspectRatio() +/* +UCHAR Video::getTVsize() { - return aspectRatio; + return ; } +*/ diff --git a/video.h b/video.h index 4ab987e..bf69200 100644 --- a/video.h +++ b/video.h @@ -42,7 +42,6 @@ class Video static Video* getInstance(); int init(UCHAR format); - int reinit(); // for aspect change int shutdown(); // Video formats - AV_SET_VID_DISP_FMT @@ -59,18 +58,28 @@ class Video // Video modes - AV_SET_VID_MODE const static UCHAR NORMAL = 0; - // if aspect==4:3 && source==4:3, output==correct-4:3 - // if aspect==4:3 && source==16:9, output==chop sides - // if aspect==16:9 && source==4:3, output==not tested, unknown - // if aspect==16:9 && source==16:9, output==stretch middle over all screen const static UCHAR LETTERBOX = 1; - // if aspect==4:3 && source==4:3, output==not tested, unknown - // if aspect==4:3 && source==16:9, output==16:9 letterbox at top of screen - // if aspect==16:9 && source==4:3, output==not tested, unknown - // if aspect==16:9 && source==16:9 output== +/* + Actual Source Aspect Aspect IOCTL Mode IOCTL MODE A MODE B + + 4:3 4:3 NORMAL fullframe43 fullframe43 + 4:3 16:9 NORMAL fullframe43 fullframe43 + 4:3 4:3 LETTERBOX fullframe43 fullframe43 + 4:3 16:9 LETTERBOX fullframe43 fullframe43 + 16:9 4:3 NORMAL chop sides fullframe169 + 16:9 16:9 NORMAL chop sides fullframe169 + 16:9 4:3 LETTERBOX letterbox letterbox + 16:9 16:9 LETTERBOX chop sides fullframe169 + + Conclusions + + 1. There are two chip modes - accessible by reopening the fd + 2. The video chip knows the aspect ratio purely from the incoming MPEG + + To switch to MODE A, set the aspect ioctl to 4:3 and reopen the FD. + To switch to MODE B, set the aspect ioctl to 16:9 and reopen the FD. +*/ - // If aspect==4:3, 4:3 unknown / 16:9 letterbox at top of screen (!!) - // If aspect==16:9, 4:3 unknown / 16:9 proper 16:9 mode const static UCHAR UNKNOWN2 = 2; const static UCHAR QUARTER = 3; const static UCHAR EIGHTH = 4; @@ -79,8 +88,10 @@ class Video int setFormat(UCHAR format); int setConnection(UCHAR connection); - int setAspectRatio(UCHAR aspectRatio); - UCHAR getAspectRatio(); + int setAspectRatio(UCHAR aspectRatio); // This one does the pin 8 scart widescreen switching +// UCHAR getAspectRatio(); + int setTVsize(UCHAR size); + int setDefaultAspect(); int setMode(UCHAR mode); int setSource(); int setPosition(int x, int y); @@ -116,6 +127,7 @@ class Video int fdVideo; + UCHAR tvsize; UCHAR format; UCHAR connection; UCHAR aspectRatio; diff --git a/voptions.cc b/voptions.cc index eacc6c3..0227d89 100644 --- a/voptions.cc +++ b/voptions.cc @@ -280,16 +280,21 @@ void VOptions::doSave() else Remote::getInstance()->setRemoteType(Remote::OLDREMOTE); + Video* video = Video::getInstance(); if (!strcmp(tvconnection, "S-Video")) - Video::getInstance()->setConnection(Video::SVIDEO); + video->setConnection(Video::SVIDEO); else - Video::getInstance()->setConnection(Video::COMPOSITERGB); + video->setConnection(Video::COMPOSITERGB); if (!strcmp(aspect, "16:9")) - Video::getInstance()->setAspectRatio(Video::ASPECT16X9); + { + Log::getInstance()->log("Options", Log::DEBUG, "Setting letterbox"); + video->setTVsize(Video::ASPECT16X9); + } else - Video::getInstance()->setAspectRatio(Video::ASPECT4X3); - - Video::getInstance()->reinit(); + { + Log::getInstance()->log("Options", Log::DEBUG, "Setting normal"); + video->setTVsize(Video::ASPECT4X3); + } } diff --git a/vvideolive.cc b/vvideolive.cc index 93595d5..3e6dde2 100644 --- a/vvideolive.cc +++ b/vvideolive.cc @@ -52,6 +52,7 @@ VVideoLive::~VVideoLive() { delete player; instance = NULL; + Video::getInstance()->setDefaultAspect(); } VVideoLive* VVideoLive::getInstance() diff --git a/vvideorec.cc b/vvideorec.cc index cdc7577..a514b76 100644 --- a/vvideorec.cc +++ b/vvideorec.cc @@ -36,7 +36,10 @@ VVideoRec::VVideoRec(Recording* rec) VVideoRec::~VVideoRec() { + Log::getInstance()->log("VVideoRec", Log::DEBUG, "Pre delete player"); delete player; + Log::getInstance()->log("VVideoRec", Log::DEBUG, "Post delete player"); + Video::getInstance()->setDefaultAspect(); } void VVideoRec::draw() @@ -67,8 +70,10 @@ int VVideoRec::handleCommand(int command) case Remote::BACK: case Remote::MENU: { + Log::getInstance()->log("VVideoRec", Log::DEBUG, "Pre player stop"); player->stop(); vdr->stopStreaming(); + Log::getInstance()->log("VVideoRec", Log::DEBUG, "Post player stop"); return 4; } case Remote::PAUSE: @@ -94,13 +99,23 @@ int VVideoRec::handleCommand(int command) case Remote::YELLOW: { player->skipBackward(10); +// ((PlayerVideo*)player)->test3(); return 2; } case Remote::BLUE: { player->skipForward(10); +// ((PlayerVideo*)player)->test4(); return 2; } + +// case Remote::RADIO: +// { +// ((PlayerVideo*)player)->test5(); +// return 2; +// } + + // case Remote::REVERSE: // { // player->toggleFastBackward(); -- 2.39.5