Ticket #3395: document_dvd_functions_1.diff
File document_dvd_functions_1.diff, 9.3 KB (added by , 17 years ago) |
---|
-
DVDRingBuffer.cpp
231 231 { 232 232 blockBuf = dvdBlockWriteBuf; 233 233 234 // Use the next_cache_block instead of the next_block235 // to avoid a memcpy inside libdvdnav236 234 dvdStat = dvdnav_get_next_cache_block( 237 235 dvdnav, &blockBuf, &dvdEvent, &dvdEventSize); 238 236 … … 248 246 case DVDNAV_BLOCK_OK: 249 247 if (!seeking) 250 248 { 251 // We need at least a DVD blocks worth of data so copy it in.252 249 memcpy(dest + offset, blockBuf, DVD_BLOCK_SIZE); 253 254 250 tot += DVD_BLOCK_SIZE; 255 251 } 256 252 … … 353 349 { 354 350 buttonstreamid = 32; 355 351 int aspect = dvdnav_get_video_aspect(dvdnav); 356 // determine which subtitle stream id to use357 352 if (aspect != 0) 358 353 buttonstreamid = spu->physical_wide + buttonstreamid; 359 354 } … … 501 496 int elapsedTime = 0; 502 497 if (still->length < 0xff) 503 498 { 504 elapsedTime = stillFrameTimer.elapsed() / 1000; // in seconds499 elapsedTime = stillFrameTimer.elapsed() / 1000; 505 500 if (elapsedTime >= still->length) 506 501 SkipStillFrame(); 507 502 } … … 568 563 gotStop = false; 569 564 } 570 565 566 /** \brief get the total time of the title in seconds 567 * 90000 ticks = 1 sec 568 */ 571 569 uint DVDRingBufferPriv::GetTotalTimeOfTitle(void) 572 570 { 573 return pgcLength / 90000; // 90000 ticks = 1 second571 return pgcLength / 90000; 574 572 } 575 573 574 /** \brief get the start of the cell in seconds 575 */ 576 576 uint DVDRingBufferPriv::GetCellStart(void) 577 577 { 578 578 return cellStart / 90000; … … 590 590 dvdWaiting = false; 591 591 } 592 592 593 /** \brief jump to a dvd root or chapter menu 594 */ 593 595 bool DVDRingBufferPriv::GoToMenu(const QString str) 594 596 { 595 597 DVDMenuID_t menuid; … … 669 671 } 670 672 } 671 673 674 /** \brief action taken when a dvd menu button is selected 675 */ 672 676 void DVDRingBufferPriv::ActivateButton(void) 673 677 { 674 678 if (IsInMenu() && (NumMenuButtons() > 0)) … … 678 682 } 679 683 } 680 684 685 /** \brief get SPU pkt from dvd menu subtitle stream 686 */ 681 687 void DVDRingBufferPriv::GetMenuSPUPkt(uint8_t *buf, int buf_size, int stream_id) 682 688 { 683 689 if (buf_size < 4) … … 703 709 buttonExists = DrawMenuButton(menuSpuPkt,menuBuflength); 704 710 } 705 711 712 /** \brief returns dvd menu button if available. 713 * used by NVP::DisplayDVDButton 714 */ 706 715 AVSubtitleRect *DVDRingBufferPriv::GetMenuButton(void) 707 716 { 708 717 menuBtnLock.lock(); … … 713 722 return NULL; 714 723 } 715 724 725 716 726 void DVDRingBufferPriv::ReleaseMenuButton(void) 717 727 { 718 728 menuBtnLock.unlock(); 719 729 } 720 730 731 /** \brief obtain dvd menu button bitmap, alpha and color palette 732 */ 721 733 bool DVDRingBufferPriv::DrawMenuButton(uint8_t *spu_pkt, int buf_size) 722 734 { 723 735 int gotbutton; … … 739 751 return false; 740 752 } 741 753 754 /** \brief generate dvd subtitle bitmap or dvd menu bitmap. 755 * code obtained from ffmpeg project 756 */ 742 757 bool DVDRingBufferPriv::DecodeSubtitles(AVSubtitle *sub, int *gotSubtitles, 743 758 const uint8_t *spu_pkt, int buf_size) 744 759 { … … 938 953 return false; 939 954 } 940 955 956 /** \brief update the dvd menu button parameters 957 * when a user changes the dvd menu button position 958 */ 941 959 bool DVDRingBufferPriv::DVDButtonUpdate(bool b_mode) 942 960 { 943 961 if (!parent) … … 971 989 return false; 972 990 } 973 991 992 /** \brief clears the dvd menu button structures 993 */ 974 994 void DVDRingBufferPriv::ClearMenuButton(void) 975 995 { 976 996 if (buttonExists || dvdMenuButton.rects) … … 985 1005 } 986 1006 } 987 1007 1008 /** \brief clears the menu SPU pkt and parameters. 1009 * necessary action during dvd menu changes 1010 */ 988 1011 void DVDRingBufferPriv::ClearMenuSPUParameters(void) 989 1012 { 990 1013 if (menuBuflength == 0) … … 1010 1033 return 0; 1011 1034 } 1012 1035 1036 /** \brief get the audio language from the dvd 1037 */ 1013 1038 uint DVDRingBufferPriv::GetAudioLanguage(int id) 1014 1039 { 1015 1040 int8_t channel = dvdnav_get_audio_logical_stream(dvdnav,id); … … 1019 1044 return ConvertLangCode(lang); 1020 1045 } 1021 1046 1047 /** \brief get the subtitle language from the dvd 1048 */ 1022 1049 uint DVDRingBufferPriv::GetSubtitleLanguage(int id) 1023 1050 { 1024 1051 int8_t channel = dvdnav_get_spu_logical_stream(dvdnav,id); … … 1028 1055 return ConvertLangCode(lang); 1029 1056 } 1030 1057 1058 /** \brief converts the subtitle/audio lang code to iso639. 1059 */ 1031 1060 uint DVDRingBufferPriv::ConvertLangCode(uint16_t code) 1032 1061 { 1033 1062 if (code == 0) … … 1042 1071 return 0; 1043 1072 } 1044 1073 1074 /** \brief determines the default dvd menu button to 1075 * show when you initially access the dvd menu. 1076 */ 1045 1077 void DVDRingBufferPriv::SelectDefaultButton(void) 1046 1078 { 1047 1079 pci_t *pci = dvdnav_get_current_nav_pci(dvdnav); … … 1058 1090 dvdnav_button_select(dvdnav,pci,1); 1059 1091 } 1060 1092 1093 /** \brief set the dvd subtitle/audio track used 1094 * \param trackNo: if -1 then autoselect the track num from the dvd IFO 1095 */ 1061 1096 void DVDRingBufferPriv::SetTrack(uint type, int trackNo) 1062 1097 { 1063 1098 if (type == kTrackTypeSubtitle) … … 1075 1110 } 1076 1111 } 1077 1112 1113 /** \brief get the track the dvd should be playing. 1114 * can either be set by the user using DVDRingBufferPriv::SetTrack 1115 * or determined from the dvd IFO. 1116 * \param type: use either kTrackTypeSubtitle or kTrackTypeAudio 1117 */ 1078 1118 int DVDRingBufferPriv::GetTrack(uint type) 1079 1119 { 1080 1120 if (type == kTrackTypeSubtitle) … … 1087 1127 1088 1128 uint8_t DVDRingBufferPriv::GetNumAudioChannels(int id) 1089 1129 { 1090 unsigned char channels = dvdnav_audio_get_channels(dvdnav, id);1130 unsigned char channels = dvdnav_audio_get_channels(dvdnav, id); 1091 1131 if (channels == 0xff) 1092 1132 return 0; 1093 1133 return (uint8_t)channels + 1; 1094 1134 } 1095 1135 1136 /** \brief clear the currently displaying subtitles or 1137 * dvd menu buttons. needed for the dvd menu. 1138 */ 1096 1139 void DVDRingBufferPriv::ClearSubtitlesOSD(void) 1097 1140 { 1098 1141 if (parent && parent->GetOSD() && … … 1104 1147 } 1105 1148 1106 1149 /** \brief Get the dvd title and serial num 1107 * \return false if libdvdnav is unable to return a title and serial num1108 1150 */ 1109 1151 bool DVDRingBufferPriv::GetNameAndSerialNum(QString& _name, QString& _serial) 1110 1152 { … … 1115 1157 return true; 1116 1158 } 1117 1159 1118 /** \ fn DVDRingBufferPriv::GetFrameRate()1119 * \brief used by DecoderBase for the total frame number calculationfor position map support and ffw/rew.1160 /** \brief used by DecoderBase for the total frame number calculation 1161 * for position map support and ffw/rew. 1120 1162 * FPS for a dvd is determined by AFD::normalized_fps 1121 1163 */ 1122 1164 double DVDRingBufferPriv::GetFrameRate(void) … … 1131 1173 return dvdfps; 1132 1174 } 1133 1175 1176 /** \brief check if the current chapter is the same as 1177 * the previously accessed chapter. 1178 */ 1134 1179 bool DVDRingBufferPriv::IsSameChapter(int tmpcellid, int tmpvobid) 1135 1180 { 1136 1181 if ((tmpcellid == cellid) && (tmpvobid == vobid)) … … 1139 1184 return false; 1140 1185 } 1141 1186 1187 /** \brief seek the beginning of a dvd cell 1188 */ 1142 1189 void DVDRingBufferPriv::SeekCellStart(void) 1143 1190 { 1144 1191 QMutexLocker lock(&seekLock); … … 1156 1203 } 1157 1204 1158 1205 /** \brief set dvd speed. obtained from mplayer project 1159 * \param dvd drive speed. example if speed is 1, then function sets dvd speed to 2048kb/s 1206 * \param dvd drive speed. example if speed is 2, then function 1207 * sets dvd speed to 2048kb/s 1160 1208 */ 1161 1209 void DVDRingBufferPriv::SetDVDSpeed(int speed) 1162 1210 { … … 1263 1311 #endif 1264 1312 } 1265 1313 1266 /** 1267 * \brief converts palette values from YUV to RGB 1314 /** \brief converts palette values from YUV to RGB 1268 1315 */ 1269 1316 void DVDRingBufferPriv::guess_palette(uint32_t *rgba_palette,uint8_t *palette, 1270 1317 uint8_t *alpha) … … 1295 1342 } 1296 1343 1297 1344 /** \brief decodes the bitmap from the subtitle packet. 1298 * copied from ffmpeg's dvdsub .c.1345 * copied from ffmpeg's dvdsubdec.c. 1299 1346 */ 1300 1347 int DVDRingBufferPriv::decode_rle(uint8_t *bitmap, int linesize, int w, int h, 1301 1348 const uint8_t *buf, int nibble_offset, int buf_size) … … 1336 1383 break; 1337 1384 d += linesize; 1338 1385 x = 0; 1339 /* byte align */1340 1386 nibble_offset += (nibble_offset & 1); 1341 1387 } 1342 1388 } 1343 1389 return 0; 1344 1390 } 1345 1391 1346 /** copied from ffmpeg's dvdsub .c1392 /** copied from ffmpeg's dvdsubdec.c 1347 1393 */ 1348 1394 int DVDRingBufferPriv::get_nibble(const uint8_t *buf, int nibble_offset) 1349 1395 { -
DVDRingBuffer.h
151 151 bool cellRepeated; 152 152 int buttonstreamid; 153 153 bool gotoCellStart; 154 /// this pts is of the first video frame decoded just after reading a menu pkt.155 /// menu pkt pts is not reliable156 154 long long menupktpts; 157 155 int curAudioTrack; 158 156 int8_t curSubtitleTrack; … … 178 176 void ClearMenuSPUParameters(void); 179 177 void ClearMenuButton(void); 180 178 bool MenuButtonChanged(void); 181 uint ConvertLangCode(uint16_t code); /// converts 2char key to 3char key179 uint ConvertLangCode(uint16_t code); 182 180 void SelectDefaultButton(void); 183 181 void ClearSubtitlesOSD(void); 184 182