# HG changeset patch # User rathann # Date 1220738151 0 # Node ID 90ca650854e0ab83e6d8788f7e7efca29cae109b # Parent 4e28052eb201d0272ba557ad9dde63a35002709b Remove all trailing whitespace, patch by Erik Hovland *erik$hovland dot org% diff -r 4e28052eb201 -r 90ca650854e0 dvd_types.h --- a/dvd_types.h Sun Aug 31 18:13:23 2008 +0000 +++ b/dvd_types.h Sat Sep 06 21:55:51 2008 +0000 @@ -3,17 +3,17 @@ * * This file is part of libdvdnav, a DVD navigation library. It is a modified * file originally part of the Ogle DVD player project. - * + * * libdvdnav is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * libdvdnav is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA @@ -51,7 +51,7 @@ * (see dvdnav_get_highlight_area()) */ typedef struct { - uint32_t palette; /* The CLUT entries for the highlight palette + uint32_t palette; /* The CLUT entries for the highlight palette (4-bits per entry -> 4 entries) */ uint16_t sx,sy,ex,ey; /* The start/end x,y positions */ uint32_t pts; /* Highlight PTS to match with SPU */ @@ -76,15 +76,15 @@ /* User operation permissions */ typedef enum { - UOP_FLAG_TitleOrTimePlay = 0x00000001, - UOP_FLAG_ChapterSearchOrPlay = 0x00000002, - UOP_FLAG_TitlePlay = 0x00000004, - UOP_FLAG_Stop = 0x00000008, + UOP_FLAG_TitleOrTimePlay = 0x00000001, + UOP_FLAG_ChapterSearchOrPlay = 0x00000002, + UOP_FLAG_TitlePlay = 0x00000004, + UOP_FLAG_Stop = 0x00000008, UOP_FLAG_GoUp = 0x00000010, - UOP_FLAG_TimeOrChapterSearch = 0x00000020, - UOP_FLAG_PrevOrTopPGSearch = 0x00000040, - UOP_FLAG_NextPGSearch = 0x00000080, - UOP_FLAG_ForwardScan = 0x00000100, + UOP_FLAG_TimeOrChapterSearch = 0x00000020, + UOP_FLAG_PrevOrTopPGSearch = 0x00000040, + UOP_FLAG_NextPGSearch = 0x00000080, + UOP_FLAG_ForwardScan = 0x00000100, UOP_FLAG_BackwardScan = 0x00000200, UOP_FLAG_TitleMenuCall = 0x00000400, UOP_FLAG_RootMenuCall = 0x00000800, @@ -100,7 +100,7 @@ UOP_FLAG_SubPicStreamChange = 0x00200000, UOP_FLAG_AngleChange = 0x00400000, UOP_FLAG_KaraokeAudioPresModeChange = 0x00800000, - UOP_FLAG_VideoPresModeChange = 0x01000000 + UOP_FLAG_VideoPresModeChange = 0x01000000 } DVDUOP_t; /* Parental Level */ @@ -127,7 +127,7 @@ typedef enum { DVDFalse = 0, DVDTrue = 1 -} DVDBool_t; +} DVDBool_t; typedef DVDRegister_t DVDGPRMArray_t[16]; typedef DVDRegister_t DVDSPRMArray_t[24]; @@ -148,10 +148,10 @@ } DVDTimecode_t; /* Subpicture stream number (0-31,62,63) */ -typedef int DVDSubpictureStream_t; +typedef int DVDSubpictureStream_t; /* Audio stream number (0-7, 15(none)) */ -typedef int DVDAudioStream_t; +typedef int DVDAudioStream_t; /* The audio application mode */ typedef enum { @@ -196,7 +196,7 @@ DVD_SUBPICTURE_LANG_EXT_NormalDirectorsComments = 13, DVD_SUBPICTURE_LANG_EXT_BigDirectorsComments = 14, DVD_SUBPICTURE_LANG_EXT_ChildrensDirectorsComments = 15, -} DVDSubpictureLangExt_t; +} DVDSubpictureLangExt_t; /* Karaoke Downmix mode */ typedef enum { @@ -222,7 +222,7 @@ DVD_DISPLAY_MODE_ContentDefault = 0, DVD_DISPLAY_MODE_16x9 = 1, DVD_DISPLAY_MODE_4x3PanScan = 2, - DVD_DISPLAY_MODE_4x3Letterboxed = 3 + DVD_DISPLAY_MODE_4x3Letterboxed = 3 } DVDDisplayMode_t; /* Audio attributes */ diff -r 4e28052eb201 -r 90ca650854e0 dvdnav.c --- a/dvdnav.c Sun Aug 31 18:13:23 2008 +0000 +++ b/dvdnav.c Sat Sep 06 21:55:51 2008 +0000 @@ -1,18 +1,18 @@ -/* +/* * Copyright (C) 2000 Rich Wareham - * + * * This file is part of libdvdnav, a DVD navigation library. - * + * * libdvdnav is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * libdvdnav is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA @@ -72,14 +72,14 @@ dvdnav_read_cache_clear(this->cache); pthread_mutex_unlock(&this->vm_lock); - + return DVDNAV_STATUS_OK; } dvdnav_status_t dvdnav_open(dvdnav_t** dest, const char *path) { dvdnav_t *this; struct timeval time; - + /* Create a new structure */ fprintf(MSG_OUT, "libdvdnav: Using dvdnav version %s\n", VERSION); @@ -88,7 +88,7 @@ if(!this) return DVDNAV_STATUS_ERR; memset(this, 0, (sizeof(dvdnav_t) ) ); /* Make sure this structure is clean */ - + pthread_mutex_init(&this->vm_lock, NULL); /* Initialise the error string */ printerr(""); @@ -115,7 +115,7 @@ /* Pre-open and close a file so that the CSS-keys are cached. */ this->file = DVDOpenFile(vm_get_dvd_reader(this->vm), 0, DVD_READ_MENU_VOBS); - + /* Start the read-ahead cache. */ this->cache = dvdnav_read_cache_new(this); @@ -123,9 +123,9 @@ * gives a different start value each time a DVD is played. */ gettimeofday(&time, NULL); srand(time.tv_usec); - + dvdnav_clear(this); - + (*dest) = this; return DVDNAV_STATUS_OK; } @@ -137,13 +137,13 @@ #endif if (this->file) { - pthread_mutex_lock(&this->vm_lock); + pthread_mutex_lock(&this->vm_lock); DVDCloseFile(this->file); #ifdef LOG_DEBUG fprintf(MSG_OUT, "libdvdnav: close:file closing\n"); #endif this->file = NULL; - pthread_mutex_unlock(&this->vm_lock); + pthread_mutex_unlock(&this->vm_lock); } /* Free the VM */ @@ -159,7 +159,7 @@ dvdnav_read_cache_free(this->cache); else free(this); - + return DVDNAV_STATUS_OK; } @@ -170,14 +170,14 @@ fprintf(MSG_OUT, "libdvdnav: reset:called\n"); #endif - pthread_mutex_lock(&this->vm_lock); + pthread_mutex_lock(&this->vm_lock); #ifdef LOG_DEBUG fprintf(MSG_OUT, "libdvdnav: reseting vm\n"); #endif if(!vm_reset(this->vm, NULL)) { printerr("Error restarting the VM."); - pthread_mutex_unlock(&this->vm_lock); + pthread_mutex_unlock(&this->vm_lock); return DVDNAV_STATUS_ERR; } #ifdef LOG_DEBUG @@ -185,7 +185,7 @@ #endif result = dvdnav_clear(this); - pthread_mutex_unlock(&this->vm_lock); + pthread_mutex_unlock(&this->vm_lock); return result; } @@ -196,10 +196,10 @@ } const char* dvdnav_err_to_string(dvdnav_t *this) { - + if(!this) return "Hey! You gave me a NULL pointer you naughty person!"; - + return this->err_str; } @@ -207,22 +207,22 @@ int64_t dvdnav_convert_time(dvd_time_t *time) { int64_t result; int64_t frames; - + result = (time->hour >> 4 ) * 10 * 60 * 60 * 90000; result += (time->hour & 0x0f) * 60 * 60 * 90000; result += (time->minute >> 4 ) * 10 * 60 * 90000; result += (time->minute & 0x0f) * 60 * 90000; result += (time->second >> 4 ) * 10 * 90000; result += (time->second & 0x0f) * 90000; - + frames = ((time->frame_u & 0x30) >> 4) * 10; frames += ((time->frame_u & 0x0f) ) ; - + if (time->frame_u & 0x80) result += frames * 3000; else result += frames * 3600; - + return result; } @@ -289,22 +289,22 @@ nPacketLen = p[4] << 8 | p[5]; p += 6; navRead_DSI(nav_dsi, p+1); - } + } return 1; } return 0; } -/* DSI is used for most angle stuff. +/* DSI is used for most angle stuff. * PCI is used for only non-seemless angle stuff - */ + */ static int32_t dvdnav_get_vobu(dvdnav_t *this, dsi_t *nav_dsi, pci_t *nav_pci, dvdnav_vobu_t *vobu) { uint32_t next; int32_t angle, num_angle; vobu->vobu_start = nav_dsi->dsi_gi.nv_pck_lbn; /* Absolute offset from start of disk */ vobu->vobu_length = nav_dsi->dsi_gi.vobu_ea; /* Relative offset from vobu_start */ - + /* * If we're not at the end of this cell, we can determine the next * VOBU to display using the VOBU_SRI information section of the @@ -316,7 +316,7 @@ * DVDs are about 6 Gigs, which is only up to 0x300000 blocks * Should really assert if bit 31 != 1 */ - + #if 0 /* Old code -- may still be useful one day */ if(nav_dsi->vobu_sri.next_vobu != SRI_END_OF_CELL ) { @@ -328,22 +328,22 @@ /* Relative offset from vobu_start */ vobu->vobu_next = ( nav_dsi->vobu_sri.next_vobu & 0x3fffffff ); #endif - + vm_get_angle_info(this->vm, &angle, &num_angle); /* FIMXE: The angle reset doesn't work for some reason for the moment */ #if 0 if((num_angle < angle) && (angle != 1)) { fprintf(MSG_OUT, "libdvdnav: angle ends!\n"); - + /* This is to switch back to angle one when we * finish with angles. */ dvdnav_angle_change(this, 1); - } + } #endif if(num_angle != 0) { - + if((next = nav_pci->nsml_agli.nsml_agl_dsta[angle-1]) != 0) { if((next & 0x3fffffff) != 0) { if(next & 0x80000000) @@ -353,7 +353,7 @@ } } else if((next = nav_dsi->sml_agli.data[angle-1].address) != 0) { vobu->vobu_length = nav_dsi->sml_pbi.ilvu_ea; - + if((next & 0x80000000) && (next != 0x7fffffff)) vobu->vobu_next = - (int32_t)(next & 0x3fffffff); else @@ -379,7 +379,7 @@ int32_t *event, int32_t *len) { unsigned char *block; dvdnav_status_t status; - + block = buf; status = dvdnav_get_next_cache_block(this, &block, event, len); if (status == DVDNAV_STATUS_OK && block != buf) { @@ -406,14 +406,14 @@ return tm; } - + dvdnav_status_t dvdnav_get_next_cache_block(dvdnav_t *this, uint8_t **buf, int32_t *event, int32_t *len) { dvd_state_t *state; int32_t result; pthread_mutex_lock(&this->vm_lock); - + if(!this->started) { /* Start the VM */ if (!vm_start(this->vm)) { @@ -427,18 +427,18 @@ state = &(this->vm->state); (*event) = DVDNAV_NOP; (*len) = 0; - + /* Check the STOP flag */ if(this->vm->stopped) { vm_stop(this->vm); (*event) = DVDNAV_STOP; this->started = 0; - pthread_mutex_unlock(&this->vm_lock); + pthread_mutex_unlock(&this->vm_lock); return DVDNAV_STATUS_OK; } vm_position_get(this->vm, &this->position_next); - + #ifdef LOG_DEBUG fprintf(MSG_OUT, "libdvdnav: POS-NEXT "); vm_position_print(this->vm, &this->position_next); @@ -454,7 +454,7 @@ #endif if (this->position_next.hop_channel - this->position_current.hop_channel >= HOP_SEEK) { int32_t num_angles = 0, current; - + /* we seeked -> check for multiple angles */ vm_get_angle_info(this->vm, ¤t, &num_angles); if (num_angles > 1) { @@ -465,13 +465,13 @@ result = dvdnav_read_cache_block(this->cache, block, 1, buf); if(result <= 0) { printerr("Error reading NAV packet."); - pthread_mutex_unlock(&this->vm_lock); + pthread_mutex_unlock(&this->vm_lock); return DVDNAV_STATUS_ERR; } /* Decode nav into pci and dsi. Then get next VOBU info. */ if(!dvdnav_decode_packet(this, *buf, &this->dsi, &this->pci)) { printerr("Expected NAV packet but none found."); - pthread_mutex_unlock(&this->vm_lock); + pthread_mutex_unlock(&this->vm_lock); return DVDNAV_STATUS_ERR; } dvdnav_get_vobu(this, &this->dsi, &this->pci, &this->vobu); @@ -492,7 +492,7 @@ this->vobu.vobu_length = 0; this->vobu.blockN = 0; this->sync_wait = 0; - pthread_mutex_unlock(&this->vm_lock); + pthread_mutex_unlock(&this->vm_lock); return DVDNAV_STATUS_OK; } @@ -508,10 +508,10 @@ hevent->display = 1; hevent->buttonN = this->position_next.button; this->position_current.button = this->position_next.button; - pthread_mutex_unlock(&this->vm_lock); + pthread_mutex_unlock(&this->vm_lock); return DVDNAV_STATUS_OK; } - + /* Check the WAIT flag */ if(this->sync_wait) { (*event) = DVDNAV_WAIT; @@ -524,12 +524,12 @@ } /* Check to see if we need to change the currently opened VOB */ - if((this->position_current.vts != this->position_next.vts) || + if((this->position_current.vts != this->position_next.vts) || (this->position_current.domain != this->position_next.domain)) { dvd_read_domain_t domain; int32_t vtsN; dvdnav_vts_change_event_t *vts_event = (dvdnav_vts_change_event_t *)*buf; - + if(this->file) { DVDCloseFile(this->file); this->file = NULL; @@ -537,7 +537,7 @@ vts_event->old_vtsN = this->position_current.vts; vts_event->old_domain = this->position_current.domain; - + /* Use the DOMAIN to find whether to open menu or title VOBs */ switch(this->position_next.domain) { case FP_DOMAIN: @@ -547,29 +547,29 @@ break; case VTSM_DOMAIN: domain = DVD_READ_MENU_VOBS; - vtsN = this->position_next.vts; + vtsN = this->position_next.vts; break; case VTS_DOMAIN: domain = DVD_READ_TITLE_VOBS; - vtsN = this->position_next.vts; + vtsN = this->position_next.vts; break; default: printerr("Unknown domain when changing VTS."); - pthread_mutex_unlock(&this->vm_lock); + pthread_mutex_unlock(&this->vm_lock); return DVDNAV_STATUS_ERR; } - - this->position_current.vts = this->position_next.vts; + + this->position_current.vts = this->position_next.vts; this->position_current.domain = this->position_next.domain; dvdnav_read_cache_clear(this->cache); this->file = DVDOpenFile(vm_get_dvd_reader(this->vm), vtsN, domain); - vts_event->new_vtsN = this->position_next.vts; - vts_event->new_domain = this->position_next.domain; + vts_event->new_vtsN = this->position_next.vts; + vts_event->new_domain = this->position_next.domain; /* If couldn't open the file for some reason, moan */ if(this->file == NULL) { printerrf("Error opening vtsN=%i, domain=%i.", vtsN, domain); - pthread_mutex_unlock(&this->vm_lock); + pthread_mutex_unlock(&this->vm_lock); return DVDNAV_STATUS_ERR; } @@ -584,26 +584,26 @@ this->position_current.cell = -1; /* Force an update */ this->position_current.spu_channel = -1; /* Force an update */ this->position_current.audio_channel = -1; /* Force an update */; - - pthread_mutex_unlock(&this->vm_lock); + + pthread_mutex_unlock(&this->vm_lock); return DVDNAV_STATUS_OK; } - /* Check if the cell changed */ + /* Check if the cell changed */ if( (this->position_current.cell != this->position_next.cell) || (this->position_current.cell_restart != this->position_next.cell_restart) || (this->position_current.cell_start != this->position_next.cell_start) ) { dvdnav_cell_change_event_t *cell_event = (dvdnav_cell_change_event_t *)*buf; int32_t first_cell_nr, last_cell_nr, i; dvd_state_t *state = &this->vm->state; - + this->cur_cell_time = 0; (*event) = DVDNAV_CELL_CHANGE; #ifdef LOG_DEBUG fprintf(MSG_OUT, "libdvdnav: CELL_CHANGE\n"); #endif (*len) = sizeof(dvdnav_cell_change_event_t); - + cell_event->cellN = state->cellN; cell_event->pgN = state->pgN; cell_event->cell_length = @@ -636,23 +636,23 @@ this->position_current.cell_restart = this->position_next.cell_restart; this->position_current.cell_start = this->position_next.cell_start; this->position_current.block = this->position_next.block; - + /* vobu info is used for mid cell resumes */ this->vobu.vobu_start = this->position_next.cell_start + this->position_next.block; this->vobu.vobu_next = 0; /* Make blockN == vobu_length to do expected_nav */ this->vobu.vobu_length = 0; this->vobu.blockN = 0; - + /* update the spu palette at least on PGC changes */ this->spu_clut_changed = 1; this->position_current.spu_channel = -1; /* Force an update */ this->position_current.audio_channel = -1; /* Force an update */ - pthread_mutex_unlock(&this->vm_lock); + pthread_mutex_unlock(&this->vm_lock); return DVDNAV_STATUS_OK; } - + /* has the CLUT changed? */ if(this->spu_clut_changed) { (*event) = DVDNAV_SPU_CLUT_CHANGE; @@ -662,11 +662,11 @@ (*len) = 16 * sizeof(uint32_t); memcpy(*buf, &(state->pgc->palette), 16 * sizeof(uint32_t)); this->spu_clut_changed = 0; - pthread_mutex_unlock(&this->vm_lock); + pthread_mutex_unlock(&this->vm_lock); return DVDNAV_STATUS_OK; } - /* has the SPU channel changed? */ + /* has the SPU channel changed? */ if(this->position_current.spu_channel != this->position_next.spu_channel) { dvdnav_spu_stream_change_event_t *stream_change = (dvdnav_spu_stream_change_event_t *)*buf; @@ -685,14 +685,14 @@ fprintf(MSG_OUT, "libdvdnav: SPU_STREAM_CHANGE stream_id_pan_scan=%d\n",stream_change->physical_pan_scan); fprintf(MSG_OUT, "libdvdnav: SPU_STREAM_CHANGE returning DVDNAV_STATUS_OK\n"); #endif - pthread_mutex_unlock(&this->vm_lock); + pthread_mutex_unlock(&this->vm_lock); return DVDNAV_STATUS_OK; } - /* has the audio channel changed? */ + /* has the audio channel changed? */ if(this->position_current.audio_channel != this->position_next.audio_channel) { dvdnav_audio_stream_change_event_t *stream_change = (dvdnav_audio_stream_change_event_t *)*buf; - + (*event) = DVDNAV_AUDIO_STREAM_CHANGE; #ifdef LOG_DEBUG fprintf(MSG_OUT, "libdvdnav: AUDIO_STREAM_CHANGE\n"); @@ -704,10 +704,10 @@ #ifdef LOG_DEBUG fprintf(MSG_OUT, "libdvdnav: AUDIO_STREAM_CHANGE stream_id=%d returning DVDNAV_STATUS_OK\n",stream_change->physical); #endif - pthread_mutex_unlock(&this->vm_lock); + pthread_mutex_unlock(&this->vm_lock); return DVDNAV_STATUS_OK; } - + /* Check the STILLFRAME flag */ if(this->position_current.still != 0) { dvdnav_still_event_t *still_event = (dvdnav_still_event_t *)*buf; @@ -718,7 +718,7 @@ #endif (*len) = sizeof(dvdnav_still_event_t); still_event->length = this->position_current.still; - pthread_mutex_unlock(&this->vm_lock); + pthread_mutex_unlock(&this->vm_lock); return DVDNAV_STATUS_OK; } @@ -750,11 +750,11 @@ /* handle related state changes in next iteration */ (*event) = DVDNAV_NOP; (*len) = 0; - pthread_mutex_unlock(&this->vm_lock); + pthread_mutex_unlock(&this->vm_lock); return DVDNAV_STATUS_OK; } - /* Perform remapping jump if necessary (this is always a + /* Perform remapping jump if necessary (this is always a * VOBU boundary). */ if (this->vm->map) { this->vobu.vobu_next = remap_block( this->vm->map, @@ -768,13 +768,13 @@ if(result <= 0) { printerr("Error reading NAV packet."); - pthread_mutex_unlock(&this->vm_lock); + pthread_mutex_unlock(&this->vm_lock); return DVDNAV_STATUS_ERR; } /* Decode nav into pci and dsi. Then get next VOBU info. */ if(!dvdnav_decode_packet(this, *buf, &this->dsi, &this->pci)) { printerr("Expected NAV packet but none found."); - pthread_mutex_unlock(&this->vm_lock); + pthread_mutex_unlock(&this->vm_lock); return DVDNAV_STATUS_ERR; } /* We need to update the vm state->blockN with which VOBU we are in. @@ -782,32 +782,32 @@ */ this->vm->state.blockN = this->vobu.vobu_start - this->position_current.cell_start; - dvdnav_get_vobu(this, &this->dsi, &this->pci, &this->vobu); + dvdnav_get_vobu(this, &this->dsi, &this->pci, &this->vobu); this->vobu.blockN = 0; /* Give the cache a hint about the size of next VOBU. * This improves pre-caching, because the VOBU will almost certainly be read entirely. */ dvdnav_pre_cache_blocks(this->cache, this->vobu.vobu_start+1, this->vobu.vobu_length+1); - + /* release NAV menu filter, when we reach the same NAV packet again */ if (this->last_cmd_nav_lbn == this->pci.pci_gi.nv_pck_lbn) this->last_cmd_nav_lbn = SRI_END_OF_CELL; - + /* Successfully got a NAV packet */ (*event) = DVDNAV_NAV_PACKET; #ifdef LOG_DEBUG fprintf(MSG_OUT, "libdvdnav: NAV_PACKET\n"); #endif - (*len) = 2048; + (*len) = 2048; this->cur_cell_time = dvdnav_convert_time(&this->dsi.dsi_gi.c_eltm); - pthread_mutex_unlock(&this->vm_lock); + pthread_mutex_unlock(&this->vm_lock); return DVDNAV_STATUS_OK; } - + /* If we've got here, it must just be a normal block. */ if(!this->file) { printerr("Attempting to read without opening file."); - pthread_mutex_unlock(&this->vm_lock); + pthread_mutex_unlock(&this->vm_lock); return DVDNAV_STATUS_ERR; } @@ -815,13 +815,13 @@ result = dvdnav_read_cache_block(this->cache, this->vobu.vobu_start + this->vobu.blockN, 1, buf); if(result <= 0) { printerr("Error reading from DVD."); - pthread_mutex_unlock(&this->vm_lock); + pthread_mutex_unlock(&this->vm_lock); return DVDNAV_STATUS_ERR; } (*event) = DVDNAV_BLOCK_OK; (*len) = 2048; - pthread_mutex_unlock(&this->vm_lock); + pthread_mutex_unlock(&this->vm_lock); return DVDNAV_STATUS_OK; } @@ -841,56 +841,56 @@ pthread_mutex_lock(&this->vm_lock); retval = (uint8_t)vm_get_video_aspect(this->vm); pthread_mutex_unlock(&this->vm_lock); - + return retval; } uint8_t dvdnav_get_video_scale_permission(dvdnav_t *this) { uint8_t retval; - + if(!this->started) { printerr("Virtual DVD machine not started."); return -1; } - + pthread_mutex_lock(&this->vm_lock); retval = (uint8_t)vm_get_video_scale_permission(this->vm); pthread_mutex_unlock(&this->vm_lock); - + return retval; } uint16_t dvdnav_audio_stream_to_lang(dvdnav_t *this, uint8_t stream) { audio_attr_t attr; - + if(!this->started) { printerr("Virtual DVD machine not started."); return -1; } - - pthread_mutex_lock(&this->vm_lock); + + pthread_mutex_lock(&this->vm_lock); attr = vm_get_audio_attr(this->vm, stream); - pthread_mutex_unlock(&this->vm_lock); - + pthread_mutex_unlock(&this->vm_lock); + if(attr.lang_type != 1) return 0xffff; - + return attr.lang_code; } uint16_t dvdnav_audio_stream_format(dvdnav_t *this, uint8_t stream) { audio_attr_t attr; uint16_t format; - + if(!this->started) { printerr("Virtual DVD machine not started."); return -1; /* 0xffff */ } - - pthread_mutex_lock(&this->vm_lock); + + pthread_mutex_lock(&this->vm_lock); attr = vm_get_audio_attr(this->vm, stream); - pthread_mutex_unlock(&this->vm_lock); - + pthread_mutex_unlock(&this->vm_lock); + switch(attr.audio_format) { case 0: format = DVDNAV_FORMAT_AC3; @@ -908,11 +908,11 @@ case 7: format = DVDNAV_FORMAT_SDDS; break; - default: + default: format = 0xffff; break; } - + return format; } @@ -933,38 +933,38 @@ uint16_t dvdnav_spu_stream_to_lang(dvdnav_t *this, uint8_t stream) { subp_attr_t attr; - + if(!this->started) { printerr("Virtual DVD machine not started."); return -1; } - - pthread_mutex_lock(&this->vm_lock); + + pthread_mutex_lock(&this->vm_lock); attr = vm_get_subp_attr(this->vm, stream); - pthread_mutex_unlock(&this->vm_lock); - + pthread_mutex_unlock(&this->vm_lock); + if(attr.type != 1) return 0xffff; - + return attr.lang_code; } int8_t dvdnav_get_audio_logical_stream(dvdnav_t *this, uint8_t audio_num) { int8_t retval; - + if(!this->started) { printerr("Virtual DVD machine not started."); return -1; } - + pthread_mutex_lock(&this->vm_lock); if (!this->vm->state.pgc) { printerr("No current PGC."); - pthread_mutex_unlock(&this->vm_lock); + pthread_mutex_unlock(&this->vm_lock); return -1; } retval = vm_get_audio_stream(this->vm, audio_num); - pthread_mutex_unlock(&this->vm_lock); + pthread_mutex_unlock(&this->vm_lock); return retval; } @@ -977,7 +977,7 @@ pthread_mutex_lock(&this->vm_lock); if (!this->vm->state.pgc) { printerr("No current PGC."); - pthread_mutex_unlock(&this->vm_lock); + pthread_mutex_unlock(&this->vm_lock); return -1; } *audio_attr=vm_get_audio_attr(this->vm, audio_num); @@ -997,7 +997,7 @@ pthread_mutex_lock(&this->vm_lock); if (!this->vm->state.pgc) { printerr("No current PGC."); - pthread_mutex_unlock(&this->vm_lock); + pthread_mutex_unlock(&this->vm_lock); return -1; } retval = vm_get_subp_stream(this->vm, subp_num, 0); @@ -1014,7 +1014,7 @@ pthread_mutex_lock(&this->vm_lock); if (!this->vm->state.pgc) { printerr("No current PGC."); - pthread_mutex_unlock(&this->vm_lock); + pthread_mutex_unlock(&this->vm_lock); return -1; } *subp_attr=vm_get_subp_attr(this->vm, audio_num); @@ -1029,16 +1029,16 @@ printerr("Virtual DVD machine not started."); return -1; } - - pthread_mutex_lock(&this->vm_lock); + + pthread_mutex_lock(&this->vm_lock); if (!this->vm->state.pgc) { printerr("No current PGC."); - pthread_mutex_unlock(&this->vm_lock); + pthread_mutex_unlock(&this->vm_lock); return -1; } retval = vm_get_audio_active_stream(this->vm); - pthread_mutex_unlock(&this->vm_lock); - + pthread_mutex_unlock(&this->vm_lock); + return retval; } @@ -1049,31 +1049,31 @@ printerr("Virtual DVD machine not started."); return -1; } - - pthread_mutex_lock(&this->vm_lock); + + pthread_mutex_lock(&this->vm_lock); if (!this->vm->state.pgc) { printerr("No current PGC."); - pthread_mutex_unlock(&this->vm_lock); + pthread_mutex_unlock(&this->vm_lock); return -1; } retval = vm_get_subp_active_stream(this->vm, 0); - pthread_mutex_unlock(&this->vm_lock); - + pthread_mutex_unlock(&this->vm_lock); + return retval; } static int8_t dvdnav_is_domain(dvdnav_t *this, domain_t domain) { int8_t retval; - + if(!this->started) { printerr("Virtual DVD machine not started."); return -1; } - + pthread_mutex_lock(&this->vm_lock); retval = (this->vm->state.domain == domain); pthread_mutex_unlock(&this->vm_lock); - + return retval; } @@ -1090,14 +1090,14 @@ return dvdnav_is_domain(this, VTSM_DOMAIN); } /* Video Title domain (playing movie). */ -int8_t dvdnav_is_domain_vts(dvdnav_t *this) { +int8_t dvdnav_is_domain_vts(dvdnav_t *this) { return dvdnav_is_domain(this, VTS_DOMAIN); } /* Generally delegate angle information handling to VM */ dvdnav_status_t dvdnav_angle_change(dvdnav_t *this, int32_t angle) { int32_t num, current; - + pthread_mutex_lock(&this->vm_lock); vm_get_angle_info(this->vm, ¤t, &num); /* Set angle SPRM if valid */ @@ -1138,29 +1138,29 @@ } user_ops_t dvdnav_get_restrictions(dvdnav_t* this) { - /* - * user_ops_t is a structure of 32 bits. We want to compute - * the union of two of those bitfields so to make this quicker + /* + * user_ops_t is a structure of 32 bits. We want to compute + * the union of two of those bitfields so to make this quicker * than performing 32 ORs, we will access them as 32bits words. */ union { user_ops_t ops_struct; uint32_t ops_int; } ops; - + ops.ops_int = 0; - + if(!this->started) { printerr("Virtual DVD machine not started."); return ops.ops_struct; } - - pthread_mutex_lock(&this->vm_lock); + + pthread_mutex_lock(&this->vm_lock); ops.ops_int |= *(uint32_t*)&this->pci.pci_gi.vobu_uop_ctl; - + if(this->vm && this->vm->state.pgc) ops.ops_int |= *(uint32_t*)&this->vm->state.pgc->prohibited_ops; - pthread_mutex_unlock(&this->vm_lock); - + pthread_mutex_unlock(&this->vm_lock); + return ops.ops_struct; } diff -r 4e28052eb201 -r 90ca650854e0 dvdnav.h --- a/dvdnav.h Sun Aug 31 18:13:23 2008 +0000 +++ b/dvdnav.h Sat Sep 06 21:55:51 2008 +0000 @@ -1,18 +1,18 @@ -/* +/* * Copyright (C) 2001 Rich Wareham - * + * * This file is part of libdvdnav, a DVD navigation library. - * + * * libdvdnav is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * libdvdnav is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA @@ -95,7 +95,7 @@ dvdnav_status_t dvdnav_open(dvdnav_t **dest, const char *path); /* - * Closes a dvdnav_t previously opened with dvdnav_open(), freeing any + * Closes a dvdnav_t previously opened with dvdnav_open(), freeing any * memory associated with it. */ dvdnav_status_t dvdnav_close(dvdnav_t *self); @@ -131,7 +131,7 @@ * Sets the region mask (bit 0 set implies region 1, bit 1 set implies * region 2, etc) of the virtual machine. Generally you will only need to set * this if you are playing RCE discs which query the virtual machine as to its - * region setting. + * region setting. * * This has _nothing_ to do with the region setting of the DVD drive. */ @@ -185,12 +185,12 @@ *********************************************************************/ /* - * These functions are used to poll the playback enginge and actually get data + * These functions are used to poll the playback enginge and actually get data * off the DVD. */ /* - * Attempts to get the next block off the DVD and copies it into the buffer 'buf'. + * Attempts to get the next block off the DVD and copies it into the buffer 'buf'. * If there is any special actions that may need to be performed, the value * pointed to by 'event' gets set accordingly. * @@ -327,7 +327,7 @@ /* * Return the current position (in blocks) within the current * title and the length (in blocks) of said title. - * + * * Current implementation is wrong and likely to behave unpredictably! * Use is discouraged! */ @@ -362,7 +362,7 @@ * 'origin' can be one of SEEK_SET, SEEK_CUR, SEEK_END as defined in * fcntl.h. */ -dvdnav_status_t dvdnav_sector_search(dvdnav_t *self, +dvdnav_status_t dvdnav_sector_search(dvdnav_t *self, uint64_t offset, int32_t origin); /* @@ -377,7 +377,7 @@ * * Currently unimplemented! */ -dvdnav_status_t dvdnav_time_search(dvdnav_t *self, +dvdnav_status_t dvdnav_time_search(dvdnav_t *self, uint64_t time); /* @@ -431,7 +431,7 @@ */ /* - * Get the currently highlighted button + * Get the currently highlighted button * number (1..36) or 0 if no button is highlighted. */ dvdnav_status_t dvdnav_get_current_highlight(dvdnav_t *self, int32_t *button); @@ -503,7 +503,7 @@ * languages * *********************************************************************/ -/* +/* * The language codes expected by these functions are two character * codes as defined in ISO639. */ @@ -545,7 +545,7 @@ * Get video aspect code. * The aspect code does only change on VTS boundaries. * See the DVDNAV_VTS_CHANGE event. - * + * * 0 -- 4:3, 2 -- 16:9 */ uint8_t dvdnav_get_video_aspect(dvdnav_t *self); @@ -578,7 +578,7 @@ uint16_t dvdnav_audio_stream_channels(dvdnav_t *self, uint8_t stream); /* - * Converts a *logical* subpicture stream id into country code + * Converts a *logical* subpicture stream id into country code * (returns 0xffff if no such stream). */ uint16_t dvdnav_spu_stream_to_lang(dvdnav_t *self, uint8_t stream); @@ -615,9 +615,9 @@ */ int8_t dvdnav_get_active_spu_stream(dvdnav_t *self); -/* +/* * Get the set of user operations that are currently prohibited. - * There are potentially new restrictions right after + * There are potentially new restrictions right after * DVDNAV_CHANNEL_HOP and DVDNAV_NAV_PACKET. */ user_ops_t dvdnav_get_restrictions(dvdnav_t *self); diff -r 4e28052eb201 -r 90ca650854e0 dvdnav_events.h --- a/dvdnav_events.h Sun Aug 31 18:13:23 2008 +0000 +++ b/dvdnav_events.h Sat Sep 06 21:55:51 2008 +0000 @@ -1,18 +1,18 @@ -/* +/* * Copyright (C) 2001 Rich Wareham - * + * * This file is part of libdvdnav, a DVD navigation library. - * + * * libdvdnav is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * libdvdnav is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA @@ -22,7 +22,7 @@ */ /* - * This header defines events and event types + * This header defines events and event types */ #ifndef DVDNAV_EVENTS_H_INCLUDED @@ -87,7 +87,7 @@ * Use this, if you blend the SPU on an anamorphic image after * unsqueezing it the pan&scan way. */ int physical_pan_scan; - + /* The logical (DVD) stream number. */ int logical; } dvdnav_spu_stream_change_event_t; @@ -194,7 +194,7 @@ int display; /* FIXME: these fields are currently not set */ - uint32_t palette; /* The CLUT entries for the highlight palette + uint32_t palette; /* The CLUT entries for the highlight palette (4-bits per entry -> 4 entries) */ uint16_t sx,sy,ex,ey; /* The start/end x,y positions */ uint32_t pts; /* Highlight PTS to match with SPU */ diff -r 4e28052eb201 -r 90ca650854e0 dvdnav_internal.h --- a/dvdnav_internal.h Sun Aug 31 18:13:23 2008 +0000 +++ b/dvdnav_internal.h Sat Sep 06 21:55:51 2008 +0000 @@ -1,18 +1,18 @@ -/* +/* * Copyright (C) 2001-2004 Rich Wareham - * + * * This file is part of libdvdnav, a DVD navigation library. - * + * * libdvdnav is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * libdvdnav is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA @@ -83,7 +83,7 @@ /* * These are defined here because they are - * not in ifo_types.h, they maybe one day + * not in ifo_types.h, they maybe one day */ #ifndef audio_status_t @@ -96,7 +96,7 @@ #else uint8_t zero2; unsigned int stream_number : 3; - unsigned int zero1 : 4; + unsigned int zero1 : 4; unsigned int available : 1; #endif } ATTRIBUTE_PACKED audio_status_t; @@ -133,35 +133,35 @@ int32_t vobu_length; int32_t blockN; /* Relative offset */ int32_t vobu_next; /* Relative offset */ -} dvdnav_vobu_t; - +} dvdnav_vobu_t; + /** The main DVDNAV type **/ struct dvdnav_s { /* General data */ char path[MAX_PATH_LEN]; /* Path to DVD device/dir */ dvd_file_t *file; /* Currently opened file */ - + /* Position data */ vm_position_t position_next; vm_position_t position_current; - dvdnav_vobu_t vobu; + dvdnav_vobu_t vobu; /* NAV data */ pci_t pci; dsi_t dsi; uint32_t last_cmd_nav_lbn; /* detects when a command is issued on an already left NAV */ - + /* Flags */ int skip_still; /* Set when skipping a still */ int sync_wait; /* applications should wait till they are in sync with us */ int sync_wait_skip; /* Set when skipping wait state */ - int spu_clut_changed; /* The SPU CLUT changed */ + int spu_clut_changed; /* The SPU CLUT changed */ int started; /* vm_start has been called? */ int use_read_ahead; /* 1 - use read-ahead cache, 0 - don't */ int pgc_based; /* positioning works PGC based instead of PG based */ int cur_cell_time; /* time expired since the beginning of the current cell, read from the dsi */ - + /* VM */ vm_t *vm; pthread_mutex_t vm_lock; diff -r 4e28052eb201 -r 90ca650854e0 highlight.c --- a/highlight.c Sun Aug 31 18:13:23 2008 +0000 +++ b/highlight.c Sat Sep 06 21:55:51 2008 +0000 @@ -1,18 +1,18 @@ -/* +/* * Copyright (C) 2000 Rich Wareham - * + * * This file is part of libdvdnav, a DVD navigation library. - * + * * libdvdnav is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * libdvdnav is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA @@ -221,7 +221,7 @@ /* Simply return the appropriate value based on the SPRM */ if(((*button) = this->position_current.button) == -1) (*button) = this->vm->state.HL_BTNN_REG >> 10; - + return DVDNAV_STATUS_OK; } @@ -241,7 +241,7 @@ #ifdef BUTTON_TESTING nav_print_PCI(pci); #endif - + return &(pci->hli.btnit[button-1]); } @@ -253,7 +253,7 @@ dvdnav_status_t dvdnav_upper_button_select(dvdnav_t *this, pci_t *pci) { btni_t *button_ptr; - + if(!(button_ptr = get_current_button(this, pci))) return DVDNAV_STATUS_ERR; @@ -263,7 +263,7 @@ dvdnav_status_t dvdnav_lower_button_select(dvdnav_t *this, pci_t *pci) { btni_t *button_ptr; - + if(!(button_ptr = get_current_button(this, pci))) return DVDNAV_STATUS_ERR; @@ -273,7 +273,7 @@ dvdnav_status_t dvdnav_right_button_select(dvdnav_t *this, pci_t *pci) { btni_t *button_ptr; - + if(!(button_ptr = get_current_button(this, pci))) return DVDNAV_STATUS_ERR; @@ -283,7 +283,7 @@ dvdnav_status_t dvdnav_left_button_select(dvdnav_t *this, pci_t *pci) { btni_t *button_ptr; - + if(!(button_ptr = get_current_button(this, pci))) return DVDNAV_STATUS_ERR; @@ -291,14 +291,14 @@ return button_auto_action(this, pci); } -dvdnav_status_t dvdnav_get_highlight_area(pci_t *nav_pci , int32_t button, int32_t mode, +dvdnav_status_t dvdnav_get_highlight_area(pci_t *nav_pci , int32_t button, int32_t mode, dvdnav_highlight_area_t *highlight) { btni_t *button_ptr; #ifdef BUTTON_TESTING fprintf(MSG_OUT, "libdvdnav: Button get_highlight_area %i\n", button); #endif - + if(!nav_pci->hli.hl_gi.hli_ss) return DVDNAV_STATUS_ERR; if((button <= 0) || (button > nav_pci->hli.hl_gi.btn_ns)) @@ -341,7 +341,7 @@ printerr("This NAV has already been left."); return DVDNAV_STATUS_ERR; } - pthread_mutex_lock(&this->vm_lock); + pthread_mutex_lock(&this->vm_lock); button = this->vm->state.HL_BTNN_REG >> 10; @@ -366,10 +366,10 @@ printerr(""); return DVDNAV_STATUS_OK; } - pthread_mutex_unlock(&this->vm_lock); + pthread_mutex_unlock(&this->vm_lock); return DVDNAV_STATUS_ERR; } - + button_ptr = get_current_button(this, pci); /* Finally, make the VM execute the appropriate code and probably * scedule a jump */ @@ -382,8 +382,8 @@ this->position_current.still = 0; this->last_cmd_nav_lbn = pci->pci_gi.nv_pck_lbn; } - - pthread_mutex_unlock(&this->vm_lock); + + pthread_mutex_unlock(&this->vm_lock); return DVDNAV_STATUS_OK; } @@ -407,7 +407,7 @@ this->sync_wait = 0; pthread_mutex_unlock(&this->vm_lock); return DVDNAV_STATUS_OK; -} +} dvdnav_status_t dvdnav_button_select(dvdnav_t *this, pci_t *pci, int32_t button) { if(!pci->hli.hl_gi.hli_ss) { @@ -418,23 +418,23 @@ printerr("This NAV has already been left."); return DVDNAV_STATUS_ERR; } - + #ifdef BUTTON_TESTING - fprintf(MSG_OUT, "libdvdnav: Button select %i\n", button); + fprintf(MSG_OUT, "libdvdnav: Button select %i\n", button); #endif - + if((button <= 0) || (button > pci->hli.hl_gi.btn_ns)) { printerr("Button does not exist."); return DVDNAV_STATUS_ERR; } - + this->vm->state.HL_BTNN_REG = (button << 10); this->position_current.button = -1; /* Force Highligh change */ return DVDNAV_STATUS_OK; } -dvdnav_status_t dvdnav_button_select_and_activate(dvdnav_t *this, pci_t *pci, +dvdnav_status_t dvdnav_button_select_and_activate(dvdnav_t *this, pci_t *pci, int32_t button) { /* A trivial function */ if(dvdnav_button_select(this, pci, button) != DVDNAV_STATUS_ERR) @@ -460,7 +460,7 @@ best = 0; dist = 0x08000000; /* >> than (720*720)+(567*567); */ - + /* Loop through all buttons */ for(button = 1; button <= pci->hli.hl_gi.btn_ns; button++) { btni_t *button_ptr = &(pci->hli.btnit[button-1]); diff -r 4e28052eb201 -r 90ca650854e0 navigation.c --- a/navigation.c Sun Aug 31 18:13:23 2008 +0000 +++ b/navigation.c Sat Sep 06 21:55:51 2008 +0000 @@ -1,18 +1,18 @@ -/* +/* * Copyright (C) 2000 Rich Wareham - * + * * This file is part of libdvdnav, a DVD navigation library. - * + * * libdvdnav is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * libdvdnav is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA @@ -86,7 +86,7 @@ dvdnav_status_t dvdnav_current_title_info(dvdnav_t *this, int32_t *title, int32_t *part) { int32_t retval; - + pthread_mutex_lock(&this->vm_lock); if (!this->vm->vtsi || !this->vm->vmgi) { printerr("Bad VM state."); diff -r 4e28052eb201 -r 90ca650854e0 read_cache.c --- a/read_cache.c Sun Aug 31 18:13:23 2008 +0000 +++ b/read_cache.c Sat Sep 06 21:55:51 2008 +0000 @@ -260,7 +260,7 @@ if (use >= 0) { read_cache_chunk_t *chunk; - + /* Increment read-ahead size if sector follows the last sector */ if (sector == (self->last_sector + 1)) { if (self->read_ahead_incr < READ_AHEAD_SIZE_MAX) diff -r 4e28052eb201 -r 90ca650854e0 read_cache.h --- a/read_cache.h Sun Aug 31 18:13:23 2008 +0000 +++ b/read_cache.h Sat Sep 06 21:55:51 2008 +0000 @@ -1,18 +1,18 @@ -/* +/* * Copyright (C) 2000 Rich Wareham - * + * * This file is part of libdvdnav, a DVD navigation library. - * + * * libdvdnav is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * libdvdnav is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA @@ -28,7 +28,7 @@ /* typedef struct read_cache_s read_cache_t; */ /* EXPERIMENTAL: Setting the following to 1 will use an experimental multi-threaded - * read-ahead cache. + * read-ahead cache. */ #define _MULTITHREAD_ 0 diff -r 4e28052eb201 -r 90ca650854e0 remap.c --- a/remap.c Sun Aug 31 18:13:23 2008 +0000 +++ b/remap.c Sat Sep 06 21:55:51 2008 +0000 @@ -26,7 +26,7 @@ #include #include -#ifndef _MSC_VER +#ifndef _MSC_VER #include #include #else @@ -98,7 +98,7 @@ } else if (a->start_block > b->end_block) { /* * if a->start_block == b->end_block then the two regions - * aren't strictly overlapping, but they should be merged + * aren't strictly overlapping, but they should be merged * anyway since there are zero blocks between them */ return 1; @@ -154,7 +154,7 @@ } } -static int parseblock(char *buf, int *dom, int *tt, int *pg, +static int parseblock(char *buf, int *dom, int *tt, int *pg, unsigned long *start, unsigned long *end) { long tmp; char *tok; @@ -184,7 +184,7 @@ case 4: *end = tmp; break; - } + } st++; tok = strtok( NULL, " "); } @@ -223,7 +223,7 @@ if (strncasecmp( buf, "debug", 5) == 0) { map->debug = 1; } else { - res = parseblock( buf, + res = parseblock( buf, &tmp.domain, &tmp.title, &tmp.program, &tmp.start_block, &tmp.end_block); if (res != 5) { fprintf(MSG_OUT, "libdvdnav: Ignoring map line (%d): %s\n", res, buf); @@ -241,9 +241,9 @@ return map; } -unsigned long remap_block( - remap_t *map, int domain, int title, int program, - unsigned long cblock, unsigned long offset) +unsigned long remap_block( + remap_t *map, int domain, int title, int program, + unsigned long cblock, unsigned long offset) { block_t key; block_t *b; @@ -258,7 +258,7 @@ key.program = program; key.start_block = key.end_block = cblock + offset; b = findblock( map, &key); - + if (b) { if (map->debug) { fprintf(MSG_OUT, "libdvdnav: Redirected to %lx\n", b->end_block); diff -r 4e28052eb201 -r 90ca650854e0 remap.h --- a/remap.h Sun Aug 31 18:13:23 2008 +0000 +++ b/remap.h Sat Sep 06 21:55:51 2008 +0000 @@ -1,16 +1,16 @@ -/* +/* * This file is part of libdvdnav, a DVD navigation library. - * + * * libdvdnav is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * libdvdnav is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA @@ -26,8 +26,8 @@ remap_t* remap_loadmap( char *title); -unsigned long remap_block( - remap_t *map, int domain, int title, int program, +unsigned long remap_block( + remap_t *map, int domain, int title, int program, unsigned long cblock, unsigned long offset); #endif diff -r 4e28052eb201 -r 90ca650854e0 searching.c --- a/searching.c Sun Aug 31 18:13:23 2008 +0000 +++ b/searching.c Sat Sep 06 21:55:51 2008 +0000 @@ -1,18 +1,18 @@ /* * Copyright (C) 2000 Rich Wareham - * + * * This file is part of libdvdnav, a DVD navigation library. - * + * * libdvdnav is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * libdvdnav is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA @@ -104,7 +104,7 @@ only the cell times */ dvdnav_status_t dvdnav_time_search(dvdnav_t *this, uint64_t time) { - + uint64_t target = time; uint64_t length = 0; uint32_t first_cell_nr, last_cell_nr, cell_nr; @@ -116,7 +116,7 @@ printerr("Cannot seek in a still frame."); return DVDNAV_STATUS_ERR; } - + pthread_mutex_lock(&this->vm_lock); state = &(this->vm->state); if(!state->pgc) { @@ -125,8 +125,8 @@ return DVDNAV_STATUS_ERR; } - - this->cur_cell_time = 0; + + this->cur_cell_time = 0; if (this->pgc_based) { first_cell_nr = 1; last_cell_nr = state->pgc->nr_of_cells; @@ -152,7 +152,7 @@ /* FIXME: there must be a better way than interpolation */ target = target * (cell->last_sector - cell->first_sector + 1) / length; target += cell->first_sector; - + found = 1; break; } @@ -166,7 +166,7 @@ #endif if (dvdnav_scan_admap(this, state->domain, target, &vobu) == DVDNAV_STATUS_OK) { uint32_t start = state->pgc->cell_playback[cell_nr-1].first_sector; - + if (vm_jump_cell_block(this->vm, cell_nr, vobu - start)) { #ifdef LOG_DEBUG fprintf(MSG_OUT, "libdvdnav: After cellN=%u blockN=%u target=%x vobu=%x start=%x\n" , @@ -178,7 +178,7 @@ } } } - + fprintf(MSG_OUT, "libdvdnav: Error when seeking\n"); printerr("Error when seeking."); pthread_mutex_unlock(&this->vm_lock); @@ -199,12 +199,12 @@ printerr("Cannot seek in a still frame."); return DVDNAV_STATUS_ERR; } - + result = dvdnav_get_position(this, &target, &length); if(!result) { return DVDNAV_STATUS_ERR; } - + pthread_mutex_lock(&this->vm_lock); state = &(this->vm->state); if(!state->pgc) { @@ -213,7 +213,7 @@ return DVDNAV_STATUS_ERR; } #ifdef LOG_DEBUG - fprintf(MSG_OUT, "libdvdnav: seeking to offset=%lu pos=%u length=%u\n", offset, target, length); + fprintf(MSG_OUT, "libdvdnav: seeking to offset=%lu pos=%u length=%u\n", offset, target, length); fprintf(MSG_OUT, "libdvdnav: Before cellN=%u blockN=%u\n", state->cellN, state->blockN); #endif @@ -248,7 +248,7 @@ pthread_mutex_unlock(&this->vm_lock); return DVDNAV_STATUS_ERR; } - + this->cur_cell_time = 0; if (this->pgc_based) { first_cell_nr = 1; @@ -287,7 +287,7 @@ #endif if (dvdnav_scan_admap(this, state->domain, target, &vobu) == DVDNAV_STATUS_OK) { int32_t start = state->pgc->cell_playback[cell_nr-1].first_sector; - + if (vm_jump_cell_block(this->vm, cell_nr, vobu - start)) { #ifdef LOG_DEBUG fprintf(MSG_OUT, "libdvdnav: After cellN=%u blockN=%u target=%x vobu=%x start=%x\n" , @@ -299,9 +299,9 @@ } } } - + fprintf(MSG_OUT, "libdvdnav: Error when seeking\n"); - fprintf(MSG_OUT, "libdvdnav: FIXME: Implement seeking to location %u\n", target); + fprintf(MSG_OUT, "libdvdnav: FIXME: Implement seeking to location %u\n", target); printerr("Error when seeking."); pthread_mutex_unlock(&this->vm_lock); return DVDNAV_STATUS_ERR; @@ -309,7 +309,7 @@ dvdnav_status_t dvdnav_part_search(dvdnav_t *this, int32_t part) { int32_t title, old_part; - + if (dvdnav_current_title_info(this, &title, &old_part) == DVDNAV_STATUS_OK) return dvdnav_part_play(this, title, part); return DVDNAV_STATUS_ERR; @@ -415,14 +415,14 @@ dvdnav_status_t dvdnav_menu_call(dvdnav_t *this, DVDMenuID_t menu) { vm_t *try_vm; - + pthread_mutex_lock(&this->vm_lock); if(!this->vm->state.pgc) { printerr("No current PGC."); pthread_mutex_unlock(&this->vm_lock); return DVDNAV_STATUS_ERR; } - + this->cur_cell_time = 0; /* make a copy of current VM and try to navigate the copy to the menu */ try_vm = vm_new_copy(this->vm); @@ -434,24 +434,24 @@ vm_free_copy(try_vm); this->position_current.still = 0; this->vm->hop_channel++; - pthread_mutex_unlock(&this->vm_lock); + pthread_mutex_unlock(&this->vm_lock); return DVDNAV_STATUS_OK; } } if (menu == DVD_MENU_Escape) menu = DVD_MENU_Root; - + if (vm_jump_menu(try_vm, menu) && !try_vm->stopped) { /* merge changes on success */ vm_merge(this->vm, try_vm); vm_free_copy(try_vm); this->position_current.still = 0; this->vm->hop_channel++; - pthread_mutex_unlock(&this->vm_lock); + pthread_mutex_unlock(&this->vm_lock); return DVDNAV_STATUS_OK; } else { vm_free_copy(try_vm); printerr("No such menu or menu not reachable."); - pthread_mutex_unlock(&this->vm_lock); + pthread_mutex_unlock(&this->vm_lock); return DVDNAV_STATUS_ERR; } } @@ -511,7 +511,7 @@ } *len += cell->last_sector - cell->first_sector + 1; } - + assert((signed)*pos != -1); pthread_mutex_unlock(&this->vm_lock); @@ -543,10 +543,10 @@ first_cell = &(state->pgc->cell_playback[first_cell_nr-1]); last_cell_nr = state->pgc->nr_of_cells; last_cell = &(state->pgc->cell_playback[last_cell_nr-1]); - + *pos = cur_sector - first_cell->first_sector; *len = last_cell->last_sector - first_cell->first_sector; - + return DVDNAV_STATUS_OK; } @@ -577,15 +577,15 @@ printerr("Couldn't open IFO for chosen title, exit."); goto fail; } - + ptitle = &this->vm->vmgi->tt_srpt->title[title-1]; parts = ptitle->nr_of_ptts; ptt = ifo->vts_ptt_srpt->title[ptitle->vts_ttn-1].ptt; - + tmp = calloc(1, sizeof(uint64_t)*parts); if(!tmp) goto fail; - + length = 0; for(i=0; iprogram_map[ptt[i].pgn-1]; if(ptt[i].pgn < pgc->nr_of_programs) endcellnr = pgc->program_map[ptt[i].pgn]; else endcellnr = 0; - + do { cell = &pgc->cell_playback[cellnr-1]; if(!(cell->block_type == BLOCK_TYPE_ANGLE_BLOCK && diff -r 4e28052eb201 -r 90ca650854e0 settings.c --- a/settings.c Sun Aug 31 18:13:23 2008 +0000 +++ b/settings.c Sat Sep 06 21:55:51 2008 +0000 @@ -1,18 +1,18 @@ -/* +/* * Copyright (C) 2000 Rich Wareham - * + * * This file is part of libdvdnav, a DVD navigation library. - * + * * libdvdnav is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * libdvdnav is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA @@ -67,7 +67,7 @@ printerr("Passed illegal language code."); return DVDNAV_STATUS_ERR; } - + pthread_mutex_lock(&this->vm_lock); this->vm->state.registers.SPRM[reg] = (code[0] << 8) | code[1]; pthread_mutex_unlock(&this->vm_lock); diff -r 4e28052eb201 -r 90ca650854e0 vm/decoder.c --- a/vm/decoder.c Sun Aug 31 18:13:23 2008 +0000 +++ b/vm/decoder.c Sat Sep 06 21:55:51 2008 +0000 @@ -1,20 +1,20 @@ /* * Copyright (C) 2000, 2001 Martin Norbäck, Håkan Hjort * 2002-2004 the dvdnav project - * + * * This file is part of libdvdnav, a DVD navigation library. It is modified * from a file originally part of the Ogle DVD player. - * + * * libdvdnav is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * libdvdnav is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA @@ -49,7 +49,7 @@ uint64_t bit_mask = 0; uint64_t examining = 0; int32_t bits; - + if (count == 0) return 0; if ( ((start - count) < -1) || @@ -79,19 +79,19 @@ gettimeofday(¤t_time, NULL); time_offset.tv_sec = current_time.tv_sec - registers->GPRM_time[reg].tv_sec; time_offset.tv_usec = current_time.tv_usec - registers->GPRM_time[reg].tv_usec; - if (time_offset.tv_usec < 0) { - time_offset.tv_sec--; + if (time_offset.tv_usec < 0) { + time_offset.tv_sec--; time_offset.tv_usec += 1000000; } result = (uint16_t) (time_offset.tv_sec & 0xffff); registers->GPRM[reg]=result; - return result; + return result; } else { /* Register mode */ return registers->GPRM[reg]; } - + } static void set_GPRM(registers_t* registers, uint8_t reg, uint16_t value) { @@ -134,7 +134,7 @@ xBBB_BBBB, if immediate use all 7 bits for data else use lower four bits for the general purpose register number. */ /* Evaluates gprm or data depending on bit, data is in byte n */ -static uint16_t eval_reg_or_data_2(command_t* command, +static uint16_t eval_reg_or_data_2(command_t* command, int32_t imm, int32_t start) { if(imm) /* immediate */ return vm_getbits(command, (start - 1), 7); @@ -143,7 +143,7 @@ } -/* Compare data using operation, return result from comparison. +/* Compare data using operation, return result from comparison. Helper function for the different if functions. */ static int32_t eval_compare(uint8_t operation, uint16_t data1, uint16_t data2) { switch(operation) { @@ -172,7 +172,7 @@ static int32_t eval_if_version_1(command_t* command) { uint8_t op = vm_getbits(command, 54, 3); if(op) { - return eval_compare(op, eval_reg(command, vm_getbits(command, 39, 8)), + return eval_compare(op, eval_reg(command, vm_getbits(command, 39, 8)), eval_reg_or_data(command, vm_getbits(command, 55, 1), 31)); } return 1; @@ -183,7 +183,7 @@ static int32_t eval_if_version_2(command_t* command) { uint8_t op = vm_getbits(command, 54, 3); if(op) { - return eval_compare(op, eval_reg(command, vm_getbits(command, 15, 8)), + return eval_compare(op, eval_reg(command, vm_getbits(command, 15, 8)), eval_reg(command, vm_getbits(command, 7, 8))); } return 1; @@ -194,19 +194,19 @@ static int32_t eval_if_version_3(command_t* command) { uint8_t op = vm_getbits(command, 54, 3); if(op) { - return eval_compare(op, eval_reg(command, vm_getbits(command, 47, 8)), + return eval_compare(op, eval_reg(command, vm_getbits(command, 47, 8)), eval_reg_or_data(command, vm_getbits(command, 55, 1), 15)); } return 1; } /* Evaluate if version 4. - Has comparison data in byte 1 and 4-5 (immediate or register) + Has comparison data in byte 1 and 4-5 (immediate or register) The register in byte 1 is only the lowe nibble (4 bits) */ static int32_t eval_if_version_4(command_t* command) { uint8_t op = vm_getbits(command, 54, 3); if(op) { - return eval_compare(op, eval_reg(command, vm_getbits(command, 51, 4)), + return eval_compare(op, eval_reg(command, vm_getbits(command, 51, 4)), eval_reg_or_data(command, vm_getbits(command, 55, 1), 31)); } return 1; @@ -216,7 +216,7 @@ 0 if no new row and 256 if Break. */ static int32_t eval_special_instruction(command_t* command, int32_t cond) { int32_t line, level; - + switch(vm_getbits(command, 51, 4)) { case 0: /* NOP */ line = 0; @@ -229,7 +229,7 @@ line = 256; return cond ? 256 : 0; case 3: /* Set temporary parental level and goto */ - line = vm_getbits(command, 7, 8); + line = vm_getbits(command, 7, 8); level = vm_getbits(command, 11, 4); if(cond) { /* This always succeeds now, if we want real parental protection */ @@ -247,7 +247,7 @@ static int32_t eval_link_subins(command_t* command, int32_t cond, link_t *return_values) { uint16_t button = vm_getbits(command, 15, 6); uint8_t linkop = vm_getbits(command, 4, 5); - + if(linkop > 0x10) return 0; /* Unknown Link by Sub-Instruction command */ @@ -263,7 +263,7 @@ Actual link instruction is in return_values parameter */ static int32_t eval_link_instruction(command_t* command, int32_t cond, link_t *return_values) { uint8_t op = vm_getbits(command, 51, 4); - + switch(op) { case 1: return eval_link_subins(command, cond, return_values); @@ -295,7 +295,7 @@ returns 1 if jump or 0 if no jump actual jump instruction is in return_values parameter */ static int32_t eval_jump_instruction(command_t* command, int32_t cond, link_t *return_values) { - + switch(vm_getbits(command, 51, 4)) { case 1: return_values->command = Exit; @@ -361,12 +361,12 @@ return 0; } -/* Evaluate a set sytem register instruction +/* Evaluate a set sytem register instruction May contain a link so return the same as eval_link */ static int32_t eval_system_set(command_t* command, int32_t cond, link_t *return_values) { int32_t i; uint16_t data, data2; - + switch(vm_getbits(command, 59, 4)) { case 1: /* Set system reg 1 &| 2 &| 3 (Audio, Subp. Angle) */ for(i = 1; i <= 3; i++) { @@ -418,7 +418,7 @@ */ static void eval_set_op(command_t* command, int32_t op, int32_t reg, int32_t reg2, int32_t data) { static const int32_t shortmax = 0xffff; - int32_t tmp; + int32_t tmp; switch(op) { case 1: set_GPRM(command->registers, reg, data); @@ -589,11 +589,11 @@ } /* Evaluate a set of commands in the given register set (which is modified) */ -int32_t vmEval_CMD(vm_cmd_t commands[], int32_t num_commands, +int32_t vmEval_CMD(vm_cmd_t commands[], int32_t num_commands, registers_t *registers, link_t *return_values) { int32_t i = 0; int32_t total = 0; - + #ifdef TRACE /* DEBUG */ fprintf(MSG_OUT, "libdvdnav: Registers before transaction\n"); @@ -605,25 +605,25 @@ fprintf(MSG_OUT, "libdvdnav: Single stepping commands\n"); #endif - i = 0; + i = 0; while(i < num_commands && total < 100000) { int32_t line; - + #ifdef TRACE vm_print_cmd(i, &commands[i]); #endif line = eval_command(&commands[i].bytes[0], registers, return_values); - + if (line < 0) { /* Link command */ #ifdef TRACE fprintf(MSG_OUT, "libdvdnav: Registers after transaction\n"); vm_print_registers( registers ); - fprintf(MSG_OUT, "libdvdnav: eval: Doing Link/Jump/Call\n"); + fprintf(MSG_OUT, "libdvdnav: eval: Doing Link/Jump/Call\n"); #endif return 1; } - + if (line > 0) /* Goto command */ i = line - 1; else /* Just continue on the next line */ @@ -631,7 +631,7 @@ total++; } - + memset(return_values, 0, sizeof(link_t)); #ifdef TRACE fprintf(MSG_OUT, "libdvdnav: Registers after transaction\n"); @@ -710,7 +710,7 @@ void vm_print_link(link_t value) { char *cmd = linkcmd2str(value.command); - + switch(value.command) { case LinkNoLink: case LinkTopC: @@ -748,7 +748,7 @@ fprintf(MSG_OUT, "libdvdnav: %s %d:%d\n", cmd, value.data1, value.data2); break; case JumpSS_VTSM: - fprintf(MSG_OUT, "libdvdnav: %s vts %d title %d menu %d\n", + fprintf(MSG_OUT, "libdvdnav: %s vts %d title %d menu %d\n", cmd, value.data1, value.data2, value.data3); break; case CallSS_FP: diff -r 4e28052eb201 -r 90ca650854e0 vm/decoder.h --- a/vm/decoder.h Sun Aug 31 18:13:23 2008 +0000 +++ b/vm/decoder.h Sat Sep 06 21:55:51 2008 +0000 @@ -1,19 +1,19 @@ /* * Copyright (C) 2000, 2001 Martin Norbäck, Håkan Hjort - * + * * This file is part of libdvdnav, a DVD navigation library. It is modified * from a file originally part of the Ogle DVD player. - * + * * libdvdnav is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * libdvdnav is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA @@ -95,7 +95,7 @@ /* the big VM function, executing the given commands and writing * the link where to continue, the return value indicates if a jump * has been performed */ -int32_t vmEval_CMD(vm_cmd_t commands[], int32_t num_commands, +int32_t vmEval_CMD(vm_cmd_t commands[], int32_t num_commands, registers_t *registers, link_t *return_values); /* extracts some bits from the command */ diff -r 4e28052eb201 -r 90ca650854e0 vm/vm.c --- a/vm/vm.c Sun Aug 31 18:13:23 2008 +0000 +++ b/vm/vm.c Sat Sep 06 21:55:51 2008 +0000 @@ -2,20 +2,20 @@ * Copyright (C) 2000, 2001 Håkan Hjort * Copyright (C) 2001 Rich Wareham * 2002-2004 the dvdnav project - * + * * This file is part of libdvdnav, a DVD navigation library. It is modified * from a file originally part of the Ogle DVD player. - * + * * libdvdnav is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * libdvdnav is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA @@ -114,7 +114,7 @@ fprintf(MSG_OUT, "libdvdnav: Video Manager Menu Domain: -\n"); break; - case FP_DOMAIN: + case FP_DOMAIN: fprintf(MSG_OUT, "libdvdnav: First Play Domain: -\n"); break; @@ -122,7 +122,7 @@ fprintf(MSG_OUT, "libdvdnav: Unknown Domain: -\n"); break; } - fprintf(MSG_OUT, "libdvdnav: VTS:%d PGC:%d PG:%u CELL:%u BLOCK:%u VTS_TTN:%u TTN:%u TT_PGCN:%u\n", + fprintf(MSG_OUT, "libdvdnav: VTS:%d PGC:%d PG:%u CELL:%u BLOCK:%u VTS_TTN:%u TTN:%u TT_PGCN:%u\n", (vm->state).vtsN, get_PGCN(vm), (vm->state).pgN, @@ -144,10 +144,10 @@ /* Read DVD name */ fd = open(device, O_RDONLY); - if (fd > 0) { + if (fd > 0) { off = lseek( fd, 32 * (off_t) DVD_VIDEO_LB_LEN, SEEK_SET ); if( off == ( 32 * (off_t) DVD_VIDEO_LB_LEN ) ) { - off = read( fd, data, DVD_VIDEO_LB_LEN ); + off = read( fd, data, DVD_VIDEO_LB_LEN ); close(fd); if (off == ( (off_t) DVD_VIDEO_LB_LEN )) { fprintf(MSG_OUT, "libdvdnav: DVD Title: "); @@ -168,7 +168,7 @@ fprintf(MSG_OUT, "%c", data[i]); } else { fprintf(MSG_OUT, " "); - } + } } fprintf(MSG_OUT, "\nlibdvdnav: DVD Title (Alternative): "); for(i=89; i < 128; i++ ) { @@ -196,10 +196,10 @@ if((vm->state).vtsN == vtsN) { return 1; /* We alread have it */ } - + if(vm->vtsi != NULL) ifoClose(vm->vtsi); - + vm->vtsi = ifoOpenVTSI(dvd, vtsN); if(vm->vtsi == NULL) { fprintf(MSG_OUT, "libdvdnav: ifoOpenVTSI failed\n"); @@ -226,7 +226,7 @@ return 0; } (vm->state).vtsN = vtsN; - + return 1; } @@ -285,7 +285,7 @@ } vm->stopped = 1; } - + int vm_reset(vm_t *vm, const char *dvdroot) { /* Setup State */ memset((vm->state).registers.SPRM, 0, sizeof((vm->state).registers.SPRM)); @@ -308,7 +308,7 @@ (vm->state).registers.SPRM[18] = ('e'<<8)|'n'; /* Initial Language Code for Spu */ (vm->state).registers.SPRM[20] = 0x1; /* Player Regional Code Mask. Region free! */ (vm->state).registers.SPRM[14] = 0x100; /* Try Pan&Scan */ - + (vm->state).pgN = 0; (vm->state).cellN = 0; (vm->state).cell_restart = 0; @@ -317,9 +317,9 @@ (vm->state).rsm_vtsN = 0; (vm->state).rsm_cellN = 0; (vm->state).rsm_blockN = 0; - + (vm->state).vtsN = -1; - + if (vm->dvd && dvdroot) { /* a new dvd device has been requested */ vm_stop(vm); @@ -383,11 +383,11 @@ int vtsN; int pgcN = get_PGCN(source); int pgN = (source->state).pgN; - + assert(pgcN); - + memcpy(target, source, sizeof(vm_t)); - + /* open a new vtsi handle, because the copy might switch to another VTS */ target->vtsi = NULL; vtsN = (target->state).vtsN; @@ -395,13 +395,13 @@ (target->state).vtsN = 0; if (!ifoOpenNewVTSI(target, target->dvd, vtsN)) assert(0); - + /* restore pgc pointer into the new vtsi */ if (!set_PGCN(target, pgcN)) assert(0); (target->state).pgN = pgN; } - + return target; } @@ -423,8 +423,8 @@ void vm_position_get(vm_t *vm, vm_position_t *position) { position->button = (vm->state).HL_BTNN_REG >> 10; - position->vts = (vm->state).vtsN; - position->domain = (vm->state).domain; + position->vts = (vm->state).vtsN; + position->domain = (vm->state).domain; position->spu_channel = (vm->state).SPST_REG; position->audio_channel = (vm->state).AST_REG; position->angle_channel = (vm->state).AGL_REG; @@ -494,7 +494,7 @@ int vm_jump_title_part(vm_t *vm, int title, int part) { link_t link; - + if(!set_PTT(vm, title, part)) return 0; /* Some DVDs do not want us to jump directly into a title and have @@ -551,7 +551,7 @@ int vm_jump_menu(vm_t *vm, DVDMenuID_t menuid) { domain_t old_domain = (vm->state).domain; - + switch ((vm->state).domain) { case VTS_DOMAIN: set_RSMinfo(vm, 0, (vm->state).blockN); @@ -581,7 +581,7 @@ case FP_DOMAIN: /* FIXME XXX $$$ What should we do here? */ break; } - + return 0; } @@ -597,7 +597,7 @@ int vm_exec_cmd(vm_t *vm, vm_cmd_t *cmd) { link_t link_values; - + if(vmEval_CMD(cmd, 1, &(vm->state).registers, &link_values)) return process_command(vm, link_values); else @@ -647,7 +647,7 @@ } vts_ttn++; part++; - + if (!found) { fprintf(MSG_OUT, "libdvdnav: chapter NOT FOUND!\n"); return 0; @@ -677,17 +677,17 @@ if((vm->state).domain != VTS_DOMAIN) audioN = 0; - + if(audioN < 8) { - /* Is there any control info for this logical stream */ + /* Is there any control info for this logical stream */ if((vm->state).pgc->audio_control[audioN] & (1<<15)) { - streamN = ((vm->state).pgc->audio_control[audioN] >> 8) & 0x07; + streamN = ((vm->state).pgc->audio_control[audioN] >> 8) & 0x07; } } - + if((vm->state).domain != VTS_DOMAIN && streamN == -1) streamN = 0; - + /* FIXME: Should also check in vtsi/vmgi status what kind of stream * it is (ac3/lpcm/dts/sdds...) to find the right (sub)stream id */ return streamN; @@ -702,15 +702,15 @@ int vm_get_subp_stream(vm_t *vm, int subpN, int mode) { int streamN = -1; int source_aspect = vm_get_video_aspect(vm); - + if((vm->state).domain != VTS_DOMAIN) subpN = 0; - + if(subpN < 32) { /* a valid logical stream */ - /* Is this logical stream present */ + /* Is this logical stream present */ if((vm->state).pgc->subp_control[subpN] & (1<<31)) { - if(source_aspect == 0) /* 4:3 */ - streamN = ((vm->state).pgc->subp_control[subpN] >> 24) & 0x1f; + if(source_aspect == 0) /* 4:3 */ + streamN = ((vm->state).pgc->subp_control[subpN] >> 24) & 0x1f; if(source_aspect == 3) /* 16:9 */ switch (mode) { case 0: @@ -724,7 +724,7 @@ } } } - + if((vm->state).domain != VTS_DOMAIN && streamN == -1) streamN = 0; @@ -737,7 +737,7 @@ int streamN; audioN = (vm->state).AST_REG ; streamN = vm_get_audio_stream(vm, audioN); - + /* If no such stream, then select the first one that exists. */ if(streamN == -1) { for(audioN = 0; audioN < 8; audioN++) { @@ -756,7 +756,7 @@ int streamN; subpN = (vm->state).SPST_REG & ~0x40; streamN = vm_get_subp_stream(vm, subpN, mode); - + /* If no such stream, then select the first one that exists. */ if(streamN == -1) { for(subpN = 0; subpN < 32; subpN++) { @@ -777,16 +777,16 @@ void vm_get_angle_info(vm_t *vm, int *current, int *num_avail) { *num_avail = 1; *current = 1; - + if((vm->state).domain == VTS_DOMAIN) { title_info_t *title; /* TTN_REG does not allways point to the correct title.. */ if((vm->state).TTN_REG > vm->vmgi->tt_srpt->nr_of_srpts) return; title = &vm->vmgi->tt_srpt->title[(vm->state).TTN_REG - 1]; - if(title->title_set_nr != (vm->state).vtsN || + if(title->title_set_nr != (vm->state).vtsN || title->vts_ttn != (vm->state).VTS_TTN_REG) - return; + return; *num_avail = title->nr_of_angles; *current = (vm->state).AGL_REG; } @@ -834,8 +834,8 @@ /* currently unused */ void vm_get_video_res(vm_t *vm, int *width, int *height) { video_attr_t attr = vm_get_video_attr(vm); - - if(attr.video_format != 0) + + if(attr.video_format != 0) *height = 576; else *height = 480; @@ -859,11 +859,11 @@ int vm_get_video_aspect(vm_t *vm) { int aspect = vm_get_video_attr(vm).display_aspect_ratio; - + assert(aspect == 0 || aspect == 3); (vm->state).registers.SPRM[14] &= ~(0x3 << 10); (vm->state).registers.SPRM[14] |= aspect << 10; - + return aspect; } @@ -918,7 +918,7 @@ static link_t play_PGC(vm_t *vm) { link_t link_values; - + #ifdef TRACE fprintf(MSG_OUT, "libdvdnav: play_PGC:"); if((vm->state).domain != FP_DOMAIN) { @@ -936,14 +936,14 @@ (vm->state).cellN = 0; (vm->state).blockN = 0; - /* eval -> updates the state and returns either + /* eval -> updates the state and returns either - some kind of jump (Jump(TT/SS/VTS_TTN/CallSS/link C/PG/PGC/PTTN) - just play video i.e first PG (This is what happens if you fall of the end of the pre_cmds) - or an error (are there more cases?) */ if((vm->state).pgc->command_tbl && (vm->state).pgc->command_tbl->nr_of_pre) { - if(vmEval_CMD((vm->state).pgc->command_tbl->pre_cmds, - (vm->state).pgc->command_tbl->nr_of_pre, + if(vmEval_CMD((vm->state).pgc->command_tbl->pre_cmds, + (vm->state).pgc->command_tbl->nr_of_pre, &(vm->state).registers, &link_values)) { /* link_values contains the 'jump' return value */ return link_values; @@ -954,11 +954,11 @@ } } return play_PG(vm); -} +} -static link_t play_PGC_PG(vm_t *vm, int pgN) { +static link_t play_PGC_PG(vm_t *vm, int pgN) { link_t link_values; - + #ifdef TRACE fprintf(MSG_OUT, "libdvdnav: play_PGC_PG:"); if((vm->state).domain != FP_DOMAIN) { @@ -976,14 +976,14 @@ (vm->state).cellN = 0; (vm->state).blockN = 0; - /* eval -> updates the state and returns either + /* eval -> updates the state and returns either - some kind of jump (Jump(TT/SS/VTS_TTN/CallSS/link C/PG/PGC/PTTN) - just play video i.e first PG (This is what happens if you fall of the end of the pre_cmds) - or an error (are there more cases?) */ if((vm->state).pgc->command_tbl && (vm->state).pgc->command_tbl->nr_of_pre) { - if(vmEval_CMD((vm->state).pgc->command_tbl->pre_cmds, - (vm->state).pgc->command_tbl->nr_of_pre, + if(vmEval_CMD((vm->state).pgc->command_tbl->pre_cmds, + (vm->state).pgc->command_tbl->nr_of_pre, &(vm->state).registers, &link_values)) { /* link_values contains the 'jump' return value */ return link_values; @@ -994,7 +994,7 @@ } } return play_PG(vm); -} +} static link_t play_PGC_post(vm_t *vm) { link_t link_values; @@ -1002,19 +1002,19 @@ #ifdef TRACE fprintf(MSG_OUT, "libdvdnav: play_PGC_post:\n"); #endif - - /* eval -> updates the state and returns either + + /* eval -> updates the state and returns either - some kind of jump (Jump(TT/SS/VTS_TTN/CallSS/link C/PG/PGC/PTTN) - just go to next PGC (This is what happens if you fall of the end of the post_cmds) - or an error (are there more cases?) */ if((vm->state).pgc->command_tbl && (vm->state).pgc->command_tbl->nr_of_post && vmEval_CMD((vm->state).pgc->command_tbl->post_cmds, - (vm->state).pgc->command_tbl->nr_of_post, + (vm->state).pgc->command_tbl->nr_of_post, &(vm->state).registers, &link_values)) { return link_values; } - + #ifdef TRACE fprintf(MSG_OUT, "libdvdnav: ** Fell of the end of the pgc, continuing in NextPGC\n"); #endif @@ -1030,19 +1030,19 @@ #ifdef TRACE fprintf(MSG_OUT, "libdvdnav: play_PG: (vm->state).pgN (%i)\n", (vm->state).pgN); #endif - + assert((vm->state).pgN > 0); if((vm->state).pgN > (vm->state).pgc->nr_of_programs) { #ifdef TRACE - fprintf(MSG_OUT, "libdvdnav: play_PG: (vm->state).pgN (%i) > pgc->nr_of_programs (%i)\n", + fprintf(MSG_OUT, "libdvdnav: play_PG: (vm->state).pgN (%i) > pgc->nr_of_programs (%i)\n", (vm->state).pgN, (vm->state).pgc->nr_of_programs ); #endif - assert((vm->state).pgN == (vm->state).pgc->nr_of_programs + 1); + assert((vm->state).pgN == (vm->state).pgc->nr_of_programs + 1); return play_PGC_post(vm); } - + (vm->state).cellN = (vm->state).pgc->program_map[(vm->state).pgN - 1]; - + return play_Cell(vm); } @@ -1052,17 +1052,17 @@ #ifdef TRACE fprintf(MSG_OUT, "libdvdnav: play_Cell: (vm->state).cellN (%i)\n", (vm->state).cellN); #endif - + assert((vm->state).cellN > 0); if((vm->state).cellN > (vm->state).pgc->nr_of_cells) { #ifdef TRACE - fprintf(MSG_OUT, "libdvdnav: (vm->state).cellN (%i) > pgc->nr_of_cells (%i)\n", + fprintf(MSG_OUT, "libdvdnav: (vm->state).cellN (%i) > pgc->nr_of_cells (%i)\n", (vm->state).cellN, (vm->state).pgc->nr_of_cells ); #endif - assert((vm->state).cellN == (vm->state).pgc->nr_of_cells + 1); + assert((vm->state).cellN == (vm->state).pgc->nr_of_cells + 1); return play_PGC_post(vm); } - + /* Multi angle/Interleaved */ switch((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_mode) { case 0: /* Normal */ @@ -1104,7 +1104,7 @@ default: fprintf(MSG_OUT, "libdvdnav: Cell is in block but did not enter at first cell!\n"); } - + /* Updates (vm->state).pgN and PTTN_REG */ if(!set_PGN(vm)) { /* Should not happen */ @@ -1121,19 +1121,19 @@ static link_t play_Cell_post(vm_t *vm) { cell_playback_t *cell; - + #ifdef TRACE fprintf(MSG_OUT, "libdvdnav: play_Cell_post: (vm->state).cellN (%i)\n", (vm->state).cellN); #endif - + cell = &(vm->state).pgc->cell_playback[(vm->state).cellN - 1]; - + /* Still time is already taken care of before we get called. */ - + /* Deal with a Cell command, if any */ if(cell->cell_cmd_nr != 0) { link_t link_values; - + /* These asserts are now not needed. * Some DVDs have no cell commands listed in the PGC, * but the Cell itself points to a cell command that does not exist. @@ -1162,7 +1162,7 @@ #endif } } - + /* Where to continue after playing the cell... */ /* Multi angle/Interleaved */ switch((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_mode) { @@ -1196,8 +1196,8 @@ } break; } - - /* Figure out the correct pgN for the new cell */ + + /* Figure out the correct pgN for the new cell */ if(!set_PGN(vm)) { #ifdef TRACE fprintf(MSG_OUT, "libdvdnav: last cell in this PGC\n"); @@ -1211,18 +1211,18 @@ /* link processing */ static int process_command(vm_t *vm, link_t link_values) { - + while(link_values.command != PlayThis) { - + #ifdef TRACE fprintf(MSG_OUT, "libdvdnav: Before printout starts:\n"); vm_print_link(link_values); - fprintf(MSG_OUT, "libdvdnav: Link values %i %i %i %i\n", link_values.command, + fprintf(MSG_OUT, "libdvdnav: Link values %i %i %i %i\n", link_values.command, link_values.data1, link_values.data2, link_values.data3); vm_print_current_domain_state(vm); fprintf(MSG_OUT, "libdvdnav: Before printout ends.\n"); #endif - + switch(link_values.command) { case LinkNoLink: /* BUTTON number:data1 */ @@ -1254,7 +1254,7 @@ (vm->state).cellN -= 1; link_values = play_Cell(vm); break; - + case LinkTopPG: /* Link to Top of current Program */ /* BUTTON number:data1 */ @@ -1332,34 +1332,34 @@ { /* Link to Resume point */ int i; - + /* Check and see if there is any rsm info!! */ if (!(vm->state).rsm_vtsN) { fprintf(MSG_OUT, "libdvdnav: trying to resume without any resume info set\n"); link_values.command = Exit; break; } - + (vm->state).domain = VTS_DOMAIN; if (!ifoOpenNewVTSI(vm, vm->dvd, (vm->state).rsm_vtsN)) assert(0); set_PGCN(vm, (vm->state).rsm_pgcN); - - /* These should never be set in SystemSpace and/or MenuSpace */ + + /* These should never be set in SystemSpace and/or MenuSpace */ /* (vm->state).TTN_REG = rsm_tt; ?? */ /* (vm->state).TT_PGCN_REG = (vm->state).rsm_pgcN; ?? */ for(i = 0; i < 5; i++) { (vm->state).registers.SPRM[4 + i] = (vm->state).rsm_regs[i]; } - + if(link_values.data1 != 0) (vm->state).HL_BTNN_REG = link_values.data1 << 10; - + if((vm->state).rsm_cellN == 0) { assert((vm->state).cellN); /* Checking if this ever happens */ (vm->state).pgN = 1; link_values = play_PG(vm); - } else { + } else { /* (vm->state).pgN = ?? this gets the right value in set_PGN() below */ (vm->state).cellN = (vm->state).rsm_cellN; link_values.command = PlayThis; @@ -1409,11 +1409,11 @@ (vm->state).cellN = link_values.data1; link_values = play_Cell(vm); break; - + case Exit: vm->stopped = 1; return 0; - + case JumpTT: /* Jump to VTS Title Domain */ /* Only allowed from the First Play domain(PGC) */ @@ -1448,7 +1448,7 @@ assert(0); link_values = play_PGC_PG(vm, (vm->state).pgN); break; - + case JumpSS_FP: /* Jump to First Play Domain */ /* Only allowed from the VTS Menu Domain(VTSM) */ @@ -1475,7 +1475,7 @@ /* Stop SPRM9 Timer and any GPRM counters */ /* ifoOpenNewVTSI:data1 */ /* VTS_TTN_REG:data2 */ - /* get_MENU:data3 */ + /* get_MENU:data3 */ if(link_values.data1 != 0) { if (link_values.data1 != (vm->state).vtsN) { /* the normal case */ @@ -1514,7 +1514,7 @@ assert(0); link_values = play_PGC(vm); break; - + case CallSS_FP: /* set_RSMinfo:data1 */ assert((vm->state).domain == VTS_DOMAIN); /* ?? */ @@ -1524,18 +1524,18 @@ link_values = play_PGC(vm); break; case CallSS_VMGM_MENU: - /* set_MENU:data1 */ + /* set_MENU:data1 */ /* set_RSMinfo:data2 */ assert((vm->state).domain == VTS_DOMAIN); /* ?? */ /* Must be called before domain is changed */ - set_RSMinfo(vm, link_values.data2, /* We dont have block info */ 0); + set_RSMinfo(vm, link_values.data2, /* We dont have block info */ 0); (vm->state).domain = VMGM_DOMAIN; if(!set_MENU(vm, link_values.data1)) assert(0); link_values = play_PGC(vm); break; case CallSS_VTSM: - /* set_MENU:data1 */ + /* set_MENU:data1 */ /* set_RSMinfo:data2 */ assert((vm->state).domain == VTS_DOMAIN); /* ?? */ /* Must be called before domain is changed */ @@ -1567,7 +1567,7 @@ vm_print_current_domain_state(vm); fprintf(MSG_OUT, "libdvdnav: After printout ends.\n"); #endif - + } (vm->state).blockN = link_values.data1 | (link_values.data2 << 16); return 1; @@ -1576,7 +1576,7 @@ /* Set functions */ -static int set_TT(vm_t *vm, int tt) { +static int set_TT(vm_t *vm, int tt) { return set_PTT(vm, tt, 1); } @@ -1592,21 +1592,21 @@ static int set_VTS_PTT(vm_t *vm, int vtsN, int vts_ttn, int part) { int pgcN, pgN, res; - + (vm->state).domain = VTS_DOMAIN; if (vtsN != (vm->state).vtsN) if (!ifoOpenNewVTSI(vm, vm->dvd, vtsN)) /* Also sets (vm->state).vtsN */ return 0; - + if ((vts_ttn < 1) || (vts_ttn > vm->vtsi->vts_ptt_srpt->nr_of_srpts) || (part < 1) || (part > vm->vtsi->vts_ptt_srpt->title[vts_ttn - 1].nr_of_ptts) ) { return 0; } - + pgcN = vm->vtsi->vts_ptt_srpt->title[vts_ttn - 1].ptt[part - 1].pgcn; pgN = vm->vtsi->vts_ptt_srpt->title[vts_ttn - 1].ptt[part - 1].pgn; - + (vm->state).TT_PGCN_REG = pgcN; (vm->state).PTTN_REG = part; (vm->state).TTN_REG = get_TT(vm, vtsN, vts_ttn); @@ -1614,13 +1614,13 @@ (vm->state).VTS_TTN_REG = vts_ttn; (vm->state).vtsN = vtsN; /* Not sure about this one. We can get to it easily from TTN_REG */ /* Any other registers? */ - + res = set_PGCN(vm, pgcN); /* This clobber's state.pgN (sets it to 1), but we don't want clobbering here. */ (vm->state).pgN = pgN; return res; } -static int set_FP_PGC(vm_t *vm) { +static int set_FP_PGC(vm_t *vm) { (vm->state).domain = FP_DOMAIN; if (!vm->vmgi->first_play_pgc) { return set_PGCN(vm, 1); @@ -1638,7 +1638,7 @@ static int set_PGCN(vm_t *vm, int pgcN) { pgcit_t *pgcit; - + pgcit = get_PGCIT(vm); assert(pgcit != NULL); /* ?? Make this return -1 instead */ @@ -1648,31 +1648,31 @@ #endif return 0; } - + (vm->state).pgc = pgcit->pgci_srp[pgcN - 1].pgc; (vm->state).pgcN = pgcN; (vm->state).pgN = 1; - + if((vm->state).domain == VTS_DOMAIN) (vm->state).TT_PGCN_REG = pgcN; return 1; } -/* Figure out the correct pgN from the cell and update (vm->state). */ +/* Figure out the correct pgN from the cell and update (vm->state). */ static int set_PGN(vm_t *vm) { int new_pgN = 0; - - while(new_pgN < (vm->state).pgc->nr_of_programs + + while(new_pgN < (vm->state).pgc->nr_of_programs && (vm->state).cellN >= (vm->state).pgc->program_map[new_pgN]) new_pgN++; - + if(new_pgN == (vm->state).pgc->nr_of_programs) /* We are at the last program */ if((vm->state).cellN > (vm->state).pgc->nr_of_cells) return 0; /* We are past the last cell */ - + (vm->state).pgN = new_pgN; - + if((vm->state).domain == VTS_DOMAIN) { playback_type_t *pb_ty; if((vm->state).TTN_REG > vm->vmgi->tt_srpt->nr_of_srpts) @@ -1693,7 +1693,7 @@ /* Must be called before domain is changed (set_PGCN()) */ static void set_RSMinfo(vm_t *vm, int cellN, int blockN) { int i; - + if(cellN) { (vm->state).rsm_cellN = cellN; (vm->state).rsm_blockN = blockN; @@ -1703,9 +1703,9 @@ } (vm->state).rsm_vtsN = (vm->state).vtsN; (vm->state).rsm_pgcN = get_PGCN(vm); - + /* assert((vm->state).rsm_pgcN == (vm->state).TT_PGCN_REG); for VTS_DOMAIN */ - + for(i = 0; i < 5; i++) { (vm->state).rsm_regs[i] = (vm->state).registers.SPRM[4 + i]; } @@ -1723,7 +1723,7 @@ int tt=0; for(i = 1; i <= vm->vmgi->tt_srpt->nr_of_srpts; i++) { - if( vm->vmgi->tt_srpt->title[i - 1].title_set_nr == vtsN && + if( vm->vmgi->tt_srpt->title[i - 1].title_set_nr == vtsN && vm->vmgi->tt_srpt->title[i - 1].vts_ttn == vts_ttn) { tt=i; break; @@ -1738,7 +1738,7 @@ static int get_ID(vm_t *vm, int id) { int pgcN, i; pgcit_t *pgcit; - + /* Relies on state to get the correct pgcit. */ pgcit = get_PGCIT(vm); assert(pgcit != NULL); @@ -1777,7 +1777,7 @@ int pgcN = 1; pgcit = get_PGCIT(vm); - + if (pgcit) { while(pgcN <= pgcit->nr_of_pgci_srp) { if(pgcit->pgci_srp[pgcN - 1].pgc == (vm->state).pgc) { @@ -1787,19 +1787,19 @@ pgcN++; } } - fprintf(MSG_OUT, "libdvdnav: get_PGCN failed. Was trying to find pgcN in domain %d\n", + fprintf(MSG_OUT, "libdvdnav: get_PGCN failed. Was trying to find pgcN in domain %d\n", (vm->state).domain); return 0; /* error */ } static pgcit_t* get_MENU_PGCIT(vm_t *vm, ifo_handle_t *h, uint16_t lang) { int i; - + if(h == NULL || h->pgci_ut == NULL) { fprintf(MSG_OUT, "libdvdnav: *** pgci_ut handle is NULL ***\n"); return NULL; /* error? */ } - + i = 0; while(i < h->pgci_ut->nr_of_lus && h->pgci_ut->lu[i].lang_code != lang) @@ -1818,14 +1818,14 @@ fprintf(MSG_OUT, "\n"); i = 0; /* error? */ } - + return h->pgci_ut->lu[i].pgcit; } /* Uses state to decide what to return */ static pgcit_t* get_PGCIT(vm_t *vm) { pgcit_t *pgcit = NULL; - + switch ((vm->state).domain) { case VTS_DOMAIN: if(!vm->vtsi) return NULL; @@ -1842,11 +1842,11 @@ default: abort(); } - + return pgcit; } -//return the ifo_handle_t describing required title, used to +//return the ifo_handle_t describing required title, used to //identify chapters ifo_handle_t *vm_get_title_ifo(vm_t *vm, uint32_t title) { diff -r 4e28052eb201 -r 90ca650854e0 vm/vm.h --- a/vm/vm.h Sun Aug 31 18:13:23 2008 +0000 +++ b/vm/vm.h Sat Sep 06 21:55:51 2008 +0000 @@ -1,20 +1,20 @@ /* * Copyright (C) 2000, 2001 Håkan Hjort * Copyright (C) 2001 Rich Wareham - * + * * This file is part of libdvdnav, a DVD navigation library. It is modified * from a file originally part of the Ogle DVD player. - * + * * libdvdnav is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * libdvdnav is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA @@ -33,14 +33,14 @@ VTS_DOMAIN = 2, VMGM_DOMAIN = 4, VTSM_DOMAIN = 8 -} domain_t; +} domain_t; /** * State: SPRM, GPRM, Domain, pgc, pgN, cellN, ? */ typedef struct { registers_t registers; - + domain_t domain; int vtsN; /* 0 is vmgm? */ pgc_t *pgc; /* either this or 'int pgcN' is enough? */ @@ -49,7 +49,7 @@ int cellN; int32_t cell_restart; /* get cell to restart */ int blockN; - + /* Resume info */ int rsm_vtsN; int rsm_blockN; /* of nav_packet */ diff -r 4e28052eb201 -r 90ca650854e0 vm/vmcmd.c --- a/vm/vmcmd.c Sun Aug 31 18:13:23 2008 +0000 +++ b/vm/vmcmd.c Sat Sep 06 21:55:51 2008 +0000 @@ -1,20 +1,20 @@ /* * Copyright (C) 2000, 2001 Martin Norbäck, Håkan Hjort * 2002-2004 the dvdnav project - * + * * This file is part of libdvdnav, a DVD navigation library. It is modified * from a file originally part of the Ogle DVD player. - * + * * libdvdnav is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * libdvdnav is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA @@ -160,7 +160,7 @@ static void print_reg_or_data(command_t* command, int immediate, int start) { if(immediate) { uint32_t i = vm_getbits(command, start, 16); - + fprintf(MSG_OUT, "0x%x", i); if(isprint(i & 0xff) && isprint((i>>8) & 0xff)) fprintf(MSG_OUT, " (\"%c%c\")", (char)((i>>8) & 0xff), (char)(i & 0xff)); @@ -179,7 +179,7 @@ static void print_reg_or_data_3(command_t* command, int immediate, int start) { if(immediate) { uint32_t i = vm_getbits(command, start, 16); - + fprintf(MSG_OUT, "0x%x", i); if(isprint(i & 0xff) && isprint((i>>8) & 0xff)) fprintf(MSG_OUT, " (\"%c%c\")", (char)((i>>8) & 0xff), (char)(i & 0xff)); @@ -191,7 +191,7 @@ static void print_if_version_1(command_t* command) { uint8_t op = vm_getbits(command, 54, 3); - + if(op) { fprintf(MSG_OUT, "if ("); print_g_reg(vm_getbits(command,39,8)); @@ -203,7 +203,7 @@ static void print_if_version_2(command_t* command) { uint8_t op = vm_getbits(command, 54, 3); - + if(op) { fprintf(MSG_OUT, "if ("); print_reg(vm_getbits(command, 15, 8)); @@ -215,7 +215,7 @@ static void print_if_version_3(command_t* command) { uint8_t op = vm_getbits(command, 54, 3); - + if(op) { fprintf(MSG_OUT, "if ("); print_g_reg(vm_getbits(command, 43, 4)); @@ -240,7 +240,7 @@ static void print_if_version_5(command_t* command) { uint8_t op = vm_getbits(command, 54, 3); int set_immediate = vm_getbits(command, 60, 1); - + if(op) { if (set_immediate) { fprintf(MSG_OUT, "if ("); @@ -260,7 +260,7 @@ static void print_special_instruction(command_t* command) { uint8_t op = vm_getbits(command, 51, 4); - + switch(op) { case 0: /* NOP */ fprintf(MSG_OUT, "Nop"); @@ -272,11 +272,11 @@ fprintf(MSG_OUT, "Break"); break; case 3: /* Parental level */ - fprintf(MSG_OUT, "SetTmpPML %" PRIu8 ", Goto %" PRIu8, + fprintf(MSG_OUT, "SetTmpPML %" PRIu8 ", Goto %" PRIu8, vm_getbits(command, 11, 4), vm_getbits(command, 7, 8)); break; default: - fprintf(MSG_OUT, "WARNING: Unknown special instruction (%i)", + fprintf(MSG_OUT, "WARNING: Unknown special instruction (%i)", vm_getbits(command, 51, 4)); } } @@ -284,7 +284,7 @@ static void print_linksub_instruction(command_t* command) { uint32_t linkop = vm_getbits(command, 7, 8); uint32_t button = vm_getbits(command, 15, 6); - + if(linkop < sizeof(link_table)/sizeof(link_table[0])) fprintf(MSG_OUT, "%s (button %" PRIu8 ")", link_table[linkop], button); else @@ -293,10 +293,10 @@ static void print_link_instruction(command_t* command, int optional) { uint8_t op = vm_getbits(command, 51, 4); - + if(optional && op) fprintf(MSG_OUT, ", "); - + switch(op) { case 0: if(!optional) @@ -309,15 +309,15 @@ fprintf(MSG_OUT, "LinkPGCN %" PRIu16, vm_getbits(command, 14, 15)); break; case 5: - fprintf(MSG_OUT, "LinkPTT %" PRIu16 " (button %" PRIu8 ")", + fprintf(MSG_OUT, "LinkPTT %" PRIu16 " (button %" PRIu8 ")", vm_getbits(command, 9, 10), vm_getbits(command, 15, 6)); break; case 6: - fprintf(MSG_OUT, "LinkPGN %" PRIu8 " (button %" PRIu8 ")", + fprintf(MSG_OUT, "LinkPGN %" PRIu8 " (button %" PRIu8 ")", vm_getbits(command, 6, 7), vm_getbits(command, 15, 6)); break; case 7: - fprintf(MSG_OUT, "LinkCN %" PRIu8 " (button %" PRIu8 ")", + fprintf(MSG_OUT, "LinkCN %" PRIu8 " (button %" PRIu8 ")", vm_getbits(command, 7, 8), vm_getbits(command, 15, 6)); break; default: @@ -337,7 +337,7 @@ fprintf(MSG_OUT, "JumpVTS_TT %" PRIu8, vm_getbits(command, 22, 7)); break; case 5: - fprintf(MSG_OUT, "JumpVTS_PTT %" PRIu8 ":%" PRIu16, + fprintf(MSG_OUT, "JumpVTS_PTT %" PRIu8 ":%" PRIu16, vm_getbits(command, 22, 7), vm_getbits(command, 41, 10)); break; case 6: @@ -349,7 +349,7 @@ fprintf(MSG_OUT, "JumpSS VMGM (menu %" PRIu8 ")", vm_getbits(command, 19, 4)); break; case 2: - fprintf(MSG_OUT, "JumpSS VTSM (vts %" PRIu8 ", title %" PRIu8 + fprintf(MSG_OUT, "JumpSS VTSM (vts %" PRIu8 ", title %" PRIu8 ", menu %" PRIu8 ")", vm_getbits(command, 30, 7), vm_getbits(command, 38, 7), vm_getbits(command, 19, 4)); break; case 3: @@ -364,15 +364,15 @@ vm_getbits(command, 31, 8)); break; case 1: - fprintf(MSG_OUT, "CallSS VMGM (menu %" PRIu8 + fprintf(MSG_OUT, "CallSS VMGM (menu %" PRIu8 ", rsm_cell %" PRIu8 ")", vm_getbits(command, 19, 4), vm_getbits(command, 31, 8)); break; case 2: - fprintf(MSG_OUT, "CallSS VTSM (menu %" PRIu8 + fprintf(MSG_OUT, "CallSS VTSM (menu %" PRIu8 ", rsm_cell %" PRIu8 ")", vm_getbits(command, 19, 4), vm_getbits(command, 31, 8)); break; case 3: - fprintf(MSG_OUT, "CallSS VMGM (pgc %" PRIu8 ", rsm_cell %" PRIu8 ")", + fprintf(MSG_OUT, "CallSS VMGM (pgc %" PRIu8 ", rsm_cell %" PRIu8 ")", vm_getbits(command, 46, 15), vm_getbits(command, 31, 8)); break; } @@ -386,7 +386,7 @@ int i; /* FIXME: What about SPRM11 ? Karaoke */ /* Surely there must be some system set command for that ? */ - + switch(vm_getbits(command, 59, 4)) { case 1: /* Set system reg 1 &| 2 &| 3 (Audio, Subp. Angle) */ for(i = 1; i <= 3; i++) { @@ -424,14 +424,14 @@ fprintf(MSG_OUT, " = g[%" PRIu8 "]", vm_getbits(command, 19, 4)); break; default: - fprintf(MSG_OUT, "WARNING: Unknown system set instruction (%i)", + fprintf(MSG_OUT, "WARNING: Unknown system set instruction (%i)", vm_getbits(command, 59, 4)); } } static void print_set_version_1(command_t* command) { uint8_t set_op = vm_getbits(command, 59, 4); - + if(set_op) { print_g_reg(vm_getbits(command, 35, 4)); print_set_op(set_op); @@ -443,7 +443,7 @@ static void print_set_version_2(command_t* command) { uint8_t set_op = vm_getbits(command, 59, 4); - + if(set_op) { print_g_reg(vm_getbits(command, 51, 4)); print_set_op(set_op); @@ -455,7 +455,7 @@ static void print_set_version_3(command_t* command) { uint8_t set_op = vm_getbits(command, 59, 4); - + if(set_op) { print_g_reg(vm_getbits(command, 51, 4)); print_set_op(set_op); @@ -476,7 +476,7 @@ ( (uint64_t) vm_command->bytes[5] << 16 ) | ( (uint64_t) vm_command->bytes[6] << 8 ) | (uint64_t) vm_command->bytes[7] ; - command.examined = 0; + command.examined = 0; switch(vm_getbits(&command,63,3)) { /* three first bits */ case 0: /* Special instructions */ @@ -527,7 +527,7 @@ fprintf(MSG_OUT, "WARNING: Unknown instruction type (%i)", vm_getbits(&command, 63, 3)); } /* Check if there still are bits set that were not examined */ - + if(command.instruction & ~ command.examined) { fprintf(MSG_OUT, " libdvdnav: vmcmd.c: [WARNING, unknown bits:"); fprintf(MSG_OUT, " %08"PRIx64, (command.instruction & ~ command.examined) ); diff -r 4e28052eb201 -r 90ca650854e0 vm/vmcmd.h --- a/vm/vmcmd.h Sun Aug 31 18:13:23 2008 +0000 +++ b/vm/vmcmd.h Sat Sep 06 21:55:51 2008 +0000 @@ -1,19 +1,19 @@ /* * Copyright (C) 2000, 2001 Martin Norbäck, Håkan Hjort - * + * * This file is part of libdvdnav, a DVD navigation library. It is modified * from a file originally part of the Ogle DVD player. - * + * * libdvdnav is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * libdvdnav is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA