Ticket #3395: document_dvd_functions_1.diff

File document_dvd_functions_1.diff, 9.3 KB (added by skamithi, 17 years ago)
  • DVDRingBuffer.cpp

     
    231231    {
    232232        blockBuf = dvdBlockWriteBuf;
    233233
    234         // Use the next_cache_block instead of the next_block
    235         // to avoid a memcpy inside libdvdnav
    236234        dvdStat = dvdnav_get_next_cache_block(
    237235            dvdnav, &blockBuf, &dvdEvent, &dvdEventSize);
    238236
     
    248246            case DVDNAV_BLOCK_OK:
    249247                if (!seeking)
    250248                {
    251                     // We need at least a DVD blocks worth of data so copy it in.
    252249                    memcpy(dest + offset, blockBuf, DVD_BLOCK_SIZE);
    253                        
    254250                    tot += DVD_BLOCK_SIZE;
    255251                }
    256252               
     
    353349                {
    354350                    buttonstreamid = 32;
    355351                    int aspect = dvdnav_get_video_aspect(dvdnav);
    356                     // determine which subtitle stream id to use
    357352                    if (aspect != 0)                           
    358353                        buttonstreamid = spu->physical_wide + buttonstreamid;
    359354                }
     
    501496                    int elapsedTime = 0;
    502497                    if (still->length  < 0xff)
    503498                    {
    504                         elapsedTime = stillFrameTimer.elapsed() / 1000; // in seconds
     499                        elapsedTime = stillFrameTimer.elapsed() / 1000;
    505500                        if (elapsedTime >= still->length)
    506501                            SkipStillFrame();
    507502                    }
     
    568563    gotStop = false;
    569564}
    570565
     566/** \brief get the total time of the title in seconds
     567 * 90000 ticks = 1 sec
     568 */
    571569uint DVDRingBufferPriv::GetTotalTimeOfTitle(void)
    572570{
    573     return pgcLength / 90000; // 90000 ticks = 1 second
     571    return pgcLength / 90000;
    574572}
    575573
     574/** \brief get the start of the cell in seconds
     575 */
    576576uint DVDRingBufferPriv::GetCellStart(void)
    577577{
    578578    return cellStart / 90000;
     
    590590    dvdWaiting = false;
    591591}
    592592
     593/** \brief jump to a dvd root or chapter menu
     594 */
    593595bool DVDRingBufferPriv::GoToMenu(const QString str)
    594596{
    595597    DVDMenuID_t menuid;
     
    669671    }
    670672}
    671673
     674/** \brief action taken when a dvd menu button is selected
     675 */
    672676void DVDRingBufferPriv::ActivateButton(void)
    673677{
    674678    if (IsInMenu() && (NumMenuButtons() > 0))
     
    678682    }
    679683}
    680684
     685/** \brief get SPU pkt from dvd menu subtitle stream
     686 */
    681687void DVDRingBufferPriv::GetMenuSPUPkt(uint8_t *buf, int buf_size, int stream_id)
    682688{
    683689    if (buf_size < 4)
     
    703709        buttonExists = DrawMenuButton(menuSpuPkt,menuBuflength);
    704710}
    705711
     712/** \brief returns dvd menu button if available.
     713 * used by NVP::DisplayDVDButton
     714 */
    706715AVSubtitleRect *DVDRingBufferPriv::GetMenuButton(void)
    707716{
    708717    menuBtnLock.lock();
     
    713722    return NULL;
    714723}
    715724
     725
    716726void DVDRingBufferPriv::ReleaseMenuButton(void)
    717727{
    718728    menuBtnLock.unlock();
    719729}
    720730
     731/** \brief obtain dvd menu button bitmap, alpha and color palette
     732 */
    721733bool DVDRingBufferPriv::DrawMenuButton(uint8_t *spu_pkt, int buf_size)
    722734{
    723735    int gotbutton;
     
    739751    return false;       
    740752}
    741753
     754/** \brief generate dvd subtitle bitmap or dvd menu bitmap.
     755 * code obtained from ffmpeg project
     756 */
    742757bool DVDRingBufferPriv::DecodeSubtitles(AVSubtitle *sub, int *gotSubtitles,
    743758                                    const uint8_t *spu_pkt, int buf_size)
    744759{
     
    938953    return false;
    939954}
    940955
     956/** \brief update the dvd menu button parameters
     957 * when a user changes the dvd menu button position
     958 */
    941959bool DVDRingBufferPriv::DVDButtonUpdate(bool b_mode)
    942960{
    943961    if (!parent)
     
    971989    return false;
    972990}
    973991
     992/** \brief clears the dvd menu button structures
     993 */
    974994void DVDRingBufferPriv::ClearMenuButton(void)
    975995{
    976996    if (buttonExists || dvdMenuButton.rects)
     
    9851005    }
    9861006}
    9871007
     1008/** \brief clears the menu SPU pkt and parameters.
     1009 * necessary action during dvd menu changes
     1010 */
    9881011void DVDRingBufferPriv::ClearMenuSPUParameters(void)
    9891012{
    9901013    if (menuBuflength == 0)
     
    10101033        return 0;
    10111034}
    10121035
     1036/** \brief get the audio language from the dvd
     1037 */
    10131038uint DVDRingBufferPriv::GetAudioLanguage(int id)
    10141039{
    10151040    int8_t channel = dvdnav_get_audio_logical_stream(dvdnav,id);
     
    10191044    return ConvertLangCode(lang);
    10201045}
    10211046
     1047/** \brief get the subtitle language from the dvd
     1048 */
    10221049uint DVDRingBufferPriv::GetSubtitleLanguage(int id)
    10231050{
    10241051    int8_t channel = dvdnav_get_spu_logical_stream(dvdnav,id);
     
    10281055    return ConvertLangCode(lang);
    10291056}
    10301057
     1058/** \brief converts the subtitle/audio lang code to iso639.
     1059 */
    10311060uint DVDRingBufferPriv::ConvertLangCode(uint16_t code)
    10321061{
    10331062    if (code == 0)
     
    10421071    return 0;
    10431072}
    10441073
     1074/** \brief determines the default dvd menu button to
     1075 * show when you initially access the dvd menu.
     1076 */
    10451077void DVDRingBufferPriv::SelectDefaultButton(void)
    10461078{
    10471079    pci_t *pci = dvdnav_get_current_nav_pci(dvdnav);
     
    10581090        dvdnav_button_select(dvdnav,pci,1);   
    10591091}
    10601092
     1093/** \brief set the dvd subtitle/audio track used
     1094 *  \param trackNo: if -1 then autoselect the track num from the dvd IFO
     1095 */
    10611096void DVDRingBufferPriv::SetTrack(uint type, int trackNo)
    10621097{
    10631098    if (type == kTrackTypeSubtitle)
     
    10751110    }
    10761111}
    10771112
     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 */
    10781118int DVDRingBufferPriv::GetTrack(uint type)
    10791119{
    10801120    if (type == kTrackTypeSubtitle)
     
    10871127
    10881128uint8_t DVDRingBufferPriv::GetNumAudioChannels(int id)
    10891129{
    1090     unsigned char channels = dvdnav_audio_get_channels(dvdnav,id);
     1130    unsigned char channels = dvdnav_audio_get_channels(dvdnav, id);
    10911131    if (channels == 0xff)
    10921132        return 0;
    10931133    return (uint8_t)channels + 1;
    10941134}
    10951135
     1136/** \brief clear the currently displaying subtitles or
     1137 * dvd menu buttons. needed for the dvd menu.
     1138 */
    10961139void DVDRingBufferPriv::ClearSubtitlesOSD(void)
    10971140{
    10981141    if (parent && parent->GetOSD() &&
     
    11041147}
    11051148
    11061149/** \brief Get the dvd title and serial num
    1107  *  \return false if libdvdnav is unable to return a title and serial num
    11081150 */
    11091151bool DVDRingBufferPriv::GetNameAndSerialNum(QString& _name, QString& _serial)
    11101152{
     
    11151157    return true;
    11161158}
    11171159
    1118 /** \fn DVDRingBufferPriv::GetFrameRate()
    1119  * \brief used by DecoderBase for the total frame number calculation for 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.
    11201162 * FPS for a dvd is determined by AFD::normalized_fps
    11211163 */
    11221164double DVDRingBufferPriv::GetFrameRate(void)
     
    11311173    return dvdfps;
    11321174}
    11331175
     1176/** \brief check if the current chapter is the same as
     1177 * the previously accessed chapter.
     1178 */
    11341179bool DVDRingBufferPriv::IsSameChapter(int tmpcellid, int tmpvobid)
    11351180{
    11361181    if ((tmpcellid == cellid) && (tmpvobid == vobid))
     
    11391184    return false;
    11401185}
    11411186
     1187/** \brief seek the beginning of a dvd cell
     1188 */
    11421189void DVDRingBufferPriv::SeekCellStart(void)
    11431190{
    11441191    QMutexLocker lock(&seekLock);
     
    11561203}
    11571204
    11581205/** \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
    11601208 */
    11611209void DVDRingBufferPriv::SetDVDSpeed(int speed)
    11621210{
     
    12631311#endif
    12641312}
    12651313
    1266 /**
    1267  * \brief converts palette values from YUV to RGB
     1314/** \brief converts palette values from YUV to RGB
    12681315 */
    12691316void DVDRingBufferPriv::guess_palette(uint32_t *rgba_palette,uint8_t *palette,
    12701317                                        uint8_t *alpha)
     
    12951342}
    12961343
    12971344/** \brief decodes the bitmap from the subtitle packet.
    1298  *         copied from ffmpeg's dvdsub.c.
     1345 *         copied from ffmpeg's dvdsubdec.c.
    12991346 */
    13001347int DVDRingBufferPriv::decode_rle(uint8_t *bitmap, int linesize, int w, int h,
    13011348                                  const uint8_t *buf, int nibble_offset, int buf_size)
     
    13361383                break;
    13371384            d += linesize;
    13381385            x = 0;
    1339             /* byte align */
    13401386            nibble_offset += (nibble_offset & 1);
    13411387       }
    13421388    }
    13431389    return 0;
    13441390}
    13451391
    1346 /** copied from ffmpeg's dvdsub.c
     1392/** copied from ffmpeg's dvdsubdec.c
    13471393 */
    13481394int DVDRingBufferPriv::get_nibble(const uint8_t *buf, int nibble_offset)
    13491395{
  • DVDRingBuffer.h

     
    151151    bool           cellRepeated;
    152152    int            buttonstreamid;
    153153    bool           gotoCellStart;
    154     /// this pts is of the first video frame decoded just after reading a menu pkt.
    155     /// menu pkt pts is not reliable
    156154    long long      menupktpts;
    157155    int            curAudioTrack;
    158156    int8_t         curSubtitleTrack;
     
    178176    void ClearMenuSPUParameters(void);
    179177    void ClearMenuButton(void);
    180178    bool MenuButtonChanged(void);
    181     uint ConvertLangCode(uint16_t code); /// converts 2char key to 3char key
     179    uint ConvertLangCode(uint16_t code);
    182180    void SelectDefaultButton(void);
    183181    void ClearSubtitlesOSD(void);
    184182