Ticket #1079: get-frame-timing.patch
File get-frame-timing.patch, 12.3 KB (added by , 20 years ago) |
---|
-
libs/libmythtv/NuppelVideoPlayer.h
14 14 #include "recordingprofile.h" 15 15 #include "videooutbase.h" 16 16 #include "tv_play.h" 17 #include "yuv2rgb.h" 17 18 18 19 extern "C" { 19 20 #include "filter.h" … … 213 214 void DiscardVideoFrames(bool next_frame_keyframe); 214 215 void DrawSlice(VideoFrame *frame, int x, int y, int w, int h); 215 216 217 // Preview Image stuff 218 const QImage &GetARGBFrame(const QSize &size); 219 const unsigned char *GetScaledFrame(QSize &size); 220 void ShutdownYUVResize(void); 221 216 222 // Reinit 217 223 void ReinitOSD(void); 218 224 void ReinitVideo(void); … … 493 499 NuppelVideoPlayer *setpipplayer; 494 500 bool needsetpipplayer; 495 501 502 // Preview window support 503 bool argb_need_copy; 504 unsigned char *argb_buf; 505 QSize argb_size; 506 QImage argb_scaled_img; 507 508 yuv2rgb_fun conv_yuv2rgba; 509 510 bool yuv_need_copy; 511 unsigned char *yuv_frame_scaled; 512 QSize yuv_size_scaled; 513 QSize yuv_size_unscaled; 514 ImgReSampleContext *yuv_scaler; 515 516 QMutex argb_lock; 517 496 518 // Filters 497 519 QMutex videofiltersLock; 498 520 QString videoFilterList; -
libs/libmythtv/NuppelVideoPlayer.cpp
126 126 audio_samplerate(44100), audio_stretchfactor(1.0f), 127 127 // Picture-in-Picture 128 128 pipplayer(NULL), setpipplayer(NULL), needsetpipplayer(false), 129 // Preview window support 130 argb_need_copy(false), argb_buf(NULL), argb_size(0,0), 129 131 // Filters 130 132 videoFilterList(""), 131 133 postfilt_width(0), postfilt_height(0), 132 134 videoFilters(NULL), FiltMan(new FilterManager()), 133 135 // Commercial filtering … … 185 187 bool valid = false; 186 188 uint tmp = mypage.toInt(&valid, 16); 187 189 ttPageNum = (valid) ? tmp : ttPageNum; 190 191 conv_yuv2rgba = yuv2rgb_init_mmx(32, MODE_RGB); 192 yuv_need_copy = false; 193 yuv_frame_scaled = NULL; 194 yuv_size_scaled = QSize(0,0); 195 yuv_size_unscaled = QSize(0,0); 196 yuv_scaler = NULL; 188 197 } 189 198 190 199 NuppelVideoPlayer::~NuppelVideoPlayer(void) … … 1054 1063 vidExitLock.unlock(); 1055 1064 } 1056 1065 1066 void NuppelVideoPlayer::ShutdownYUVResize(void) 1067 { 1068 if (yuv_frame_scaled) 1069 delete [] yuv_frame_scaled; 1070 if (yuv_scaler) 1071 img_resample_close(yuv_scaler); 1072 1073 yuv_frame_scaled = NULL; 1074 yuv_scaler = NULL; 1075 yuv_size_unscaled = QSize(0,0); 1076 yuv_size_scaled = QSize(0,0); 1077 } 1078 1079 const unsigned char *NuppelVideoPlayer::GetScaledFrame(QSize &size) 1080 { 1081 size = QSize(size.width() & ~0x1, size.height() & ~0x1); 1082 1083 QSize vsize = QSize(video_width, video_height); 1084 if ((vsize != yuv_size_unscaled) || (size != yuv_size_scaled)) 1085 { 1086 ShutdownYUVResize(); 1087 1088 uint sz = size.width() * size.height() * 3 / 2; 1089 yuv_frame_scaled = new unsigned char[sz + 128]; 1090 1091 yuv_size_unscaled = vsize; 1092 yuv_size_scaled = size; 1093 1094 yuv_scaler = img_resample_init( 1095 size.width(), size.height(), vsize.width(), vsize.height()); 1096 } 1097 1098 argb_lock.lock(); 1099 yuv_need_copy = true; 1100 1101 while (yuv_need_copy) 1102 { 1103 argb_lock.unlock(); 1104 usleep(5000); 1105 argb_lock.lock(); 1106 } 1107 argb_lock.unlock(); 1108 1109 return yuv_frame_scaled; 1110 } 1111 1112 #if 0 1113 const QImage &NuppelVideoPlayer::GetARGBFrame(const QSize &size) 1114 { 1115 argb_lock.lock(); 1116 argb_need_copy = true; 1117 1118 while (argb_need_copy) 1119 { 1120 argb_lock.unlock(); 1121 usleep(5000); 1122 argb_lock.lock(); 1123 } 1124 argb_lock.unlock(); 1125 1126 MythTimer timer; 1127 timer.start(); 1128 QImage img(argb_buf, argb_size.width(), argb_size.height(), 1129 32, NULL, 65536 * 65536, QImage::LittleEndian); 1130 argb_scaled_img = img.scale(size.width(), size.height()); 1131 cerr<<timer.elapsed()<<"s"; 1132 1133 return argb_scaled_img; 1134 } 1135 #else 1136 const QImage &NuppelVideoPlayer::GetARGBFrame(const QSize &Xsize) 1137 { 1138 QSize size = Xsize; 1139 1140 unsigned char *yuv_buf = (unsigned char*) GetScaledFrame(size); 1141 if (argb_size != size) 1142 { 1143 if (argb_buf) 1144 delete [] argb_buf; 1145 argb_buf = new unsigned char[size.width() * size.height() * 4]; 1146 argb_size = QSize(size.width(), size.height()); 1147 } 1148 1149 MythTimer timer; 1150 timer.start(); 1151 uint w = argb_size.width(), h = argb_size.height(); 1152 conv_yuv2rgba(argb_buf, 1153 yuv_buf, yuv_buf + (w * h), yuv_buf + (w * h * 5 / 4), 1154 w, h, w * 4, w, w / 2, 0); 1155 1156 argb_scaled_img = QImage(argb_buf, argb_size.width(), argb_size.height(), 1157 32, NULL, 65536 * 65536, QImage::LittleEndian); 1158 cerr<<timer.elapsed()<<"c"; 1159 1160 return argb_scaled_img; 1161 } 1162 #endif 1163 1057 1164 void NuppelVideoPlayer::EmbedInWidget(WId wid, int x, int y, int w, int h) 1058 1165 { 1059 1166 if (videoOutput) … … 1775 1882 1776 1883 VideoFrame *frame = videoOutput->GetLastShownFrame(); 1777 1884 1885 if (argb_need_copy) 1886 { 1887 QMutexLocker locker(&argb_lock); 1888 MythTimer timer; 1889 timer.start(); 1890 if ((argb_size.width() != video_width) || 1891 (argb_size.height() != video_height)) 1892 { 1893 if (argb_buf) 1894 delete [] argb_buf; 1895 argb_buf = new unsigned char[video_width * video_height * 4]; 1896 argb_size = QSize(video_width, video_height); 1897 } 1898 unsigned char *yuv_buf = frame->buf; 1899 uint w = video_width, h = video_height; 1900 conv_yuv2rgba(argb_buf, 1901 yuv_buf, yuv_buf + (w * h), yuv_buf + (w * h * 5 / 4), 1902 w, h, w * 4, w, w / 2, 0); 1903 argb_need_copy = false; 1904 cerr<<timer.elapsed()<<"c"; 1905 } 1906 1907 if (yuv_need_copy) 1908 { 1909 QMutexLocker locker(&argb_lock); 1910 MythTimer timer; 1911 timer.start(); 1912 AVPicture img_out, img_in; 1913 avpicture_fill(&img_out, yuv_frame_scaled, PIX_FMT_YUV420P, 1914 yuv_size_scaled.width(), yuv_size_scaled.height()); 1915 avpicture_fill(&img_in, frame->buf, PIX_FMT_YUV420P, 1916 yuv_size_unscaled.width(), yuv_size_unscaled.height()); 1917 1918 img_resample(yuv_scaler, &img_out, &img_in); 1919 yuv_need_copy = false; 1920 cerr<<timer.elapsed()<<"s"; 1921 } 1922 1778 1923 if (subtitlesOn) 1779 1924 { 1780 1925 ShowText(); -
libs/libmythtv/videoout_null.cpp
6 6 #include "videoout_null.h" 7 7 8 8 const int kNumBuffers = 31; 9 const int kNeedFreeFrames = 1;9 const int kNeedFreeFrames = 2; 10 10 const int kPrebufferFramesNormal = 12; 11 11 const int kPrebufferFramesSmall = 4; 12 12 const int kKeepPrebuffer = 2; -
libs/libmythtv/tv_rec.cpp
1212 1212 if (curRecording) 1213 1213 curRecording->UpdateInUseMark(); 1214 1214 1215 // Check for the end of the current program.. 1215 1216 if (GetState() == kState_WatchingLiveTV) 1216 1217 { 1217 bool enable_livetv_ui = false; 1218 if (pseudoLiveTVRecording && 1219 (QDateTime::currentDateTime() > recordEndTime || 1220 HasFlags(kFlagFinishRecording))) 1221 { 1218 #define LIVETV_END (now >= curRecording->endts) 1219 // use the following instead to test ringbuffer switching 1220 //#define LIVETV_END (now >= curRecording->recstartts.addSecs(60)) 1221 1222 QDateTime now = QDateTime::currentDateTime(); 1223 bool has_finish = HasFlags(kFlagFinishRecording); 1224 bool has_rec = pseudoLiveTVRecording; 1225 bool rec_soon = pendingRecording; 1226 bool enable_ui = true; 1227 1228 if (has_rec && (has_finish || (now > recordEndTime))) 1222 1229 SetPseudoLiveTVRecording(NULL); 1223 enable_livetv_ui = true; 1224 } 1225 else if (curRecording && 1226 !pseudoLiveTVRecording && !pendingRecording) 1230 else if (!has_rec && !rec_soon && curRecording && LIVETV_END) 1231 SwitchLiveTVRingBuffer(); 1232 else 1233 enable_ui = false; 1234 1235 if (enable_ui) 1227 1236 { 1228 //#define TESTING_RING_BUFFER_SWITCHING1229 #ifdef TESTING_RING_BUFFER_SWITCHING1230 if ((QDateTime::currentDateTime() >=1231 curRecording->recstartts.addSecs(60)))1232 #else1233 if ((QDateTime::currentDateTime() >= curRecording->endts))1234 #endif1235 {1236 CheckForRecGroupChange();1237 if (pseudoLiveTVRecording)1238 {1239 // If the last recording was flagged for keeping1240 // in the frontend, then add the recording rule1241 // so that transcode, commfrag, etc can be run.1242 recordEndTime =1243 GetRecordEndTime(pseudoLiveTVRecording);1244 NotifySchedulerOfRecording(curRecording);1245 }1246 else1247 {1248 SwitchLiveTVRingBuffer();1249 enable_livetv_ui = true;1250 }1251 }1252 }1253 if (enable_livetv_ui)1254 {1255 1237 VERBOSE(VB_IMPORTANT, LOC + "Enabling Full LiveTV UI."); 1256 1238 QString message = QString("LIVETV_WATCH %1 0").arg(cardid); 1257 1239 MythEvent me(message); -
libs/libmythtv/videobuffers.cpp
10 10 #include "videoout_xv.h" // for xvmc stuff 11 11 #endif 12 12 13 #define DEBUG_FRAME_LOCKS 013 #define DEBUG_FRAME_LOCKS 1 14 14 15 15 #define TRY_LOCK_SPINS 100 16 16 #define TRY_LOCK_SPINS_BEFORE_WARNING 10 -
programs/mythfrontend/playbackbox.cpp
867 867 state = kStopped; 868 868 } 869 869 870 /* if we are playing and nvp is running, then grab a new video frame */871 870 if ((state == kPlaying) && nvp->IsPlaying() && !playingSomething) 872 871 { 873 int w = 0, h = 0; 874 VideoFrame *frame = nvp->GetCurrentFrame(w, h); 875 876 if (w == 0 || h == 0 || !frame || !(frame->buf)) 877 { 878 nvp->ReleaseCurrentFrame(frame); 879 return; 880 } 881 882 unsigned char *yuv_buf = frame->buf; 883 if (conv_rgba_size.width() != w || conv_rgba_size.height() != h) 884 { 885 if (conv_rgba_buf) 886 delete [] conv_rgba_buf; 887 conv_rgba_buf = new unsigned char[w * h * 4]; 888 conv_rgba_size = QSize(w, h); 889 } 890 891 conv_yuv2rgba(conv_rgba_buf, 892 yuv_buf, yuv_buf + (w * h), yuv_buf + (w * h * 5 / 4), 893 w, h, w * 4, w, w / 2, 0); 894 895 nvp->ReleaseCurrentFrame(frame); 896 897 QImage img(conv_rgba_buf, w, h, 32, NULL, 65536 * 65536, 898 QImage::LittleEndian); 899 img = img.scale(videoRect.width(), videoRect.height()); 900 901 p->drawImage(videoRect.x(), videoRect.y(), img); 872 const QImage &frame = nvp->GetARGBFrame(videoRect.size()); 873 p->drawImage(videoRect.x(), videoRect.y(), frame); 902 874 } 903 875 904 876 /* have we timed out waiting for nvp to start? */ -
programs/mythfrontend/playbackbox.h
349 349 350 350 mutable QMutex previewGeneratorLock; 351 351 QMap<QString, PreviewGenerator*> previewGenerator; 352 353 354 QMutex xxx; 352 355 }; 353 356 354 357 #endif