Mercurial > libdvdnav.hg
comparison dvdnav.c @ 195:6b1bfe8f5283 src
Start some cleanups.
author | jcdutton |
---|---|
date | Sun, 11 May 2003 01:13:40 +0000 |
parents | 0ee10bd2292a |
children | a20a5976a207 |
comparison
equal
deleted
inserted
replaced
194:0ee10bd2292a | 195:6b1bfe8f5283 |
---|---|
207 } | 207 } |
208 | 208 |
209 /* converts a dvd_time_t to PTS ticks */ | 209 /* converts a dvd_time_t to PTS ticks */ |
210 static int64_t dvdnav_convert_time(dvd_time_t *time) { | 210 static int64_t dvdnav_convert_time(dvd_time_t *time) { |
211 int64_t result; | 211 int64_t result; |
212 int frames; | 212 int64_t frames; |
213 | 213 |
214 result = (time->hour >> 4 ) * 10 * 60 * 60 * 90000; | 214 result = (time->hour >> 4 ) * 10 * 60 * 60 * 90000; |
215 result += (time->hour & 0x0f) * 60 * 60 * 90000; | 215 result += (time->hour & 0x0f) * 60 * 60 * 90000; |
216 result += (time->minute >> 4 ) * 10 * 60 * 90000; | 216 result += (time->minute >> 4 ) * 10 * 60 * 90000; |
217 result += (time->minute & 0x0f) * 60 * 90000; | 217 result += (time->minute & 0x0f) * 60 * 90000; |
234 * Precesses said NAV packet if present. | 234 * Precesses said NAV packet if present. |
235 * | 235 * |
236 * Most of the code in here is copied from xine's MPEG demuxer | 236 * Most of the code in here is copied from xine's MPEG demuxer |
237 * so any bugs which are found in that should be corrected here also. | 237 * so any bugs which are found in that should be corrected here also. |
238 */ | 238 */ |
239 static int dvdnav_decode_packet(dvdnav_t *this, uint8_t *p, dsi_t *nav_dsi, pci_t *nav_pci) { | 239 static int32_t dvdnav_decode_packet(dvdnav_t *this, uint8_t *p, dsi_t *nav_dsi, pci_t *nav_pci) { |
240 int bMpeg1 = 0; | 240 int32_t bMpeg1 = 0; |
241 uint32_t nHeaderLen; | 241 uint32_t nHeaderLen; |
242 uint32_t nPacketLen; | 242 uint32_t nPacketLen; |
243 uint32_t nStreamID; | 243 uint32_t nStreamID; |
244 | 244 |
245 if (p[3] == 0xBA) { /* program stream pack header */ | 245 if (p[3] == 0xBA) { /* program stream pack header */ |
246 int nStuffingBytes; | 246 int32_t nStuffingBytes; |
247 | 247 |
248 bMpeg1 = (p[4] & 0x40) == 0; | 248 bMpeg1 = (p[4] & 0x40) == 0; |
249 | 249 |
250 if (bMpeg1) { | 250 if (bMpeg1) { |
251 p += 12; | 251 p += 12; |
272 nHeaderLen = 6; | 272 nHeaderLen = 6; |
273 p += nHeaderLen; | 273 p += nHeaderLen; |
274 | 274 |
275 if (nStreamID == 0xbf) { /* Private stream 2 */ | 275 if (nStreamID == 0xbf) { /* Private stream 2 */ |
276 #if 0 | 276 #if 0 |
277 int i; | 277 int32_t i; |
278 fprintf(MSG_OUT, "libdvdnav: nav packet=%u\n",p-p_start-6); | 278 fprintf(MSG_OUT, "libdvdnav: nav packet=%u\n",p-p_start-6); |
279 for(i=0;i<80;i++) | 279 for(i=0;i<80;i++) |
280 fprintf(MSG_OUT, "%02x ",p[i-6]); | 280 fprintf(MSG_OUT, "%02x ",p[i-6]); |
281 fprintf(MSG_OUT, "\n"); | 281 fprintf(MSG_OUT, "\n"); |
282 #endif | 282 #endif |
299 } | 299 } |
300 | 300 |
301 /* DSI is used for most angle stuff. | 301 /* DSI is used for most angle stuff. |
302 * PCI is used for only non-seemless angle stuff | 302 * PCI is used for only non-seemless angle stuff |
303 */ | 303 */ |
304 static int dvdnav_get_vobu(dvdnav_t *this, dsi_t *nav_dsi, pci_t *nav_pci, dvdnav_vobu_t *vobu) { | 304 static int32_t dvdnav_get_vobu(dvdnav_t *this, dsi_t *nav_dsi, pci_t *nav_pci, dvdnav_vobu_t *vobu) { |
305 uint32_t next; | 305 uint32_t next; |
306 int angle, num_angle; | 306 int32_t angle, num_angle; |
307 | 307 |
308 vobu->vobu_start = nav_dsi->dsi_gi.nv_pck_lbn; /* Absolute offset from start of disk */ | 308 vobu->vobu_start = nav_dsi->dsi_gi.nv_pck_lbn; /* Absolute offset from start of disk */ |
309 vobu->vobu_length = nav_dsi->dsi_gi.vobu_ea; /* Relative offset from vobu_start */ | 309 vobu->vobu_length = nav_dsi->dsi_gi.vobu_ea; /* Relative offset from vobu_start */ |
310 | 310 |
311 /* | 311 /* |
376 * The benefit of this first one is that no special memory management is needed. The application is | 376 * The benefit of this first one is that no special memory management is needed. The application is |
377 * the only one responsible of allocating and freeing the memory associated with the pointer. | 377 * the only one responsible of allocating and freeing the memory associated with the pointer. |
378 * The drawback is the additional memcopy. | 378 * The drawback is the additional memcopy. |
379 */ | 379 */ |
380 | 380 |
381 dvdnav_status_t dvdnav_get_next_block(dvdnav_t *this, unsigned char *buf, | 381 dvdnav_status_t dvdnav_get_next_block(dvdnav_t *this, uint8_t *buf, |
382 int *event, int *len) { | 382 int32_t *event, int32_t *len) { |
383 unsigned char *block; | 383 unsigned char *block; |
384 dvdnav_status_t status; | 384 dvdnav_status_t status; |
385 | 385 |
386 block = buf; | 386 block = buf; |
387 status = dvdnav_get_next_cache_block(this, &block, event, len); | 387 status = dvdnav_get_next_cache_block(this, &block, event, len); |
391 dvdnav_free_cache_block(this, block); | 391 dvdnav_free_cache_block(this, block); |
392 } | 392 } |
393 return status; | 393 return status; |
394 } | 394 } |
395 | 395 |
396 dvdnav_status_t dvdnav_get_next_cache_block(dvdnav_t *this, unsigned char **buf, | 396 dvdnav_status_t dvdnav_get_next_cache_block(dvdnav_t *this, uint8_t **buf, |
397 int *event, int *len) { | 397 int32_t *event, int32_t *len) { |
398 dvd_state_t *state; | 398 dvd_state_t *state; |
399 int result; | 399 int32_t result; |
400 | 400 |
401 if(!this || !event || !len || !buf || !*buf) { | 401 if(!this || !event || !len || !buf || !*buf) { |
402 printerr("Passed a NULL pointer."); | 402 printerr("Passed a NULL pointer."); |
403 return DVDNAV_STATUS_ERR; | 403 return DVDNAV_STATUS_ERR; |
404 } | 404 } |
438 (*event) = DVDNAV_HOP_CHANNEL; | 438 (*event) = DVDNAV_HOP_CHANNEL; |
439 #ifdef LOG_DEBUG | 439 #ifdef LOG_DEBUG |
440 fprintf(MSG_OUT, "libdvdnav: HOP_CHANNEL\n"); | 440 fprintf(MSG_OUT, "libdvdnav: HOP_CHANNEL\n"); |
441 #endif | 441 #endif |
442 if (this->position_next.hop_channel - this->position_current.hop_channel >= HOP_SEEK) { | 442 if (this->position_next.hop_channel - this->position_current.hop_channel >= HOP_SEEK) { |
443 int num_angles = 0, current; | 443 int32_t num_angles = 0, current; |
444 | 444 |
445 /* we seeked -> check for multiple angles */ | 445 /* we seeked -> check for multiple angles */ |
446 vm_get_angle_info(this->vm, ¤t, &num_angles); | 446 vm_get_angle_info(this->vm, ¤t, &num_angles); |
447 if (num_angles > 1) { | 447 if (num_angles > 1) { |
448 int result, block; | 448 int32_t result, block; |
449 /* we have to skip the first VOBU when seeking in a multiangle feature, | 449 /* we have to skip the first VOBU when seeking in a multiangle feature, |
450 * because it might belong to the wrong angle */ | 450 * because it might belong to the wrong angle */ |
451 block = this->position_next.cell_start + this->position_next.block; | 451 block = this->position_next.cell_start + this->position_next.block; |
452 result = dvdnav_read_cache_block(this->cache, block, 1, buf); | 452 result = dvdnav_read_cache_block(this->cache, block, 1, buf); |
453 if(result <= 0) { | 453 if(result <= 0) { |
512 | 512 |
513 /* Check to see if we need to change the currently opened VOB */ | 513 /* Check to see if we need to change the currently opened VOB */ |
514 if((this->position_current.vts != this->position_next.vts) || | 514 if((this->position_current.vts != this->position_next.vts) || |
515 (this->position_current.domain != this->position_next.domain)) { | 515 (this->position_current.domain != this->position_next.domain)) { |
516 dvd_read_domain_t domain; | 516 dvd_read_domain_t domain; |
517 int vtsN; | 517 int32_t vtsN; |
518 dvdnav_vts_change_event_t *vts_event = (dvdnav_vts_change_event_t *)*buf; | 518 dvdnav_vts_change_event_t *vts_event = (dvdnav_vts_change_event_t *)*buf; |
519 | 519 |
520 if(this->file) { | 520 if(this->file) { |
521 DVDCloseFile(this->file); | 521 DVDCloseFile(this->file); |
522 this->file = NULL; | 522 this->file = NULL; |
579 /* Check if the cell changed */ | 579 /* Check if the cell changed */ |
580 if( (this->position_current.cell != this->position_next.cell) || | 580 if( (this->position_current.cell != this->position_next.cell) || |
581 (this->position_current.cell_restart != this->position_next.cell_restart) || | 581 (this->position_current.cell_restart != this->position_next.cell_restart) || |
582 (this->position_current.cell_start != this->position_next.cell_start) ) { | 582 (this->position_current.cell_start != this->position_next.cell_start) ) { |
583 dvdnav_cell_change_event_t *cell_event = (dvdnav_cell_change_event_t *)*buf; | 583 dvdnav_cell_change_event_t *cell_event = (dvdnav_cell_change_event_t *)*buf; |
584 int first_cell_nr, last_cell_nr, i; | 584 int32_t first_cell_nr, last_cell_nr, i; |
585 dvd_state_t *state = &this->vm->state; | 585 dvd_state_t *state = &this->vm->state; |
586 | 586 |
587 (*event) = DVDNAV_CELL_CHANGE; | 587 (*event) = DVDNAV_CELL_CHANGE; |
588 #ifdef LOG_DEBUG | 588 #ifdef LOG_DEBUG |
589 fprintf(MSG_OUT, "libdvdnav: CELL_CHANGE\n"); | 589 fprintf(MSG_OUT, "libdvdnav: CELL_CHANGE\n"); |
1039 int8_t dvdnav_is_domain_vts(dvdnav_t *this) { | 1039 int8_t dvdnav_is_domain_vts(dvdnav_t *this) { |
1040 return dvdnav_is_domain(this, VTS_DOMAIN); | 1040 return dvdnav_is_domain(this, VTS_DOMAIN); |
1041 } | 1041 } |
1042 | 1042 |
1043 /* Generally delegate angle information handling to VM */ | 1043 /* Generally delegate angle information handling to VM */ |
1044 dvdnav_status_t dvdnav_angle_change(dvdnav_t *this, int angle) { | 1044 dvdnav_status_t dvdnav_angle_change(dvdnav_t *this, int32_t angle) { |
1045 int num, current; | 1045 int32_t num, current; |
1046 | 1046 |
1047 if(!this) { | 1047 if(!this) { |
1048 printerr("Passed a NULL pointer."); | 1048 printerr("Passed a NULL pointer."); |
1049 return DVDNAV_STATUS_ERR; | 1049 return DVDNAV_STATUS_ERR; |
1050 } | 1050 } |
1062 pthread_mutex_unlock(&this->vm_lock); | 1062 pthread_mutex_unlock(&this->vm_lock); |
1063 | 1063 |
1064 return DVDNAV_STATUS_OK; | 1064 return DVDNAV_STATUS_OK; |
1065 } | 1065 } |
1066 | 1066 |
1067 dvdnav_status_t dvdnav_get_angle_info(dvdnav_t *this, int *current_angle, | 1067 dvdnav_status_t dvdnav_get_angle_info(dvdnav_t *this, int32_t *current_angle, |
1068 int *number_of_angles) { | 1068 int32_t *number_of_angles) { |
1069 if(!this || !current_angle || !number_of_angles) { | 1069 if(!this || !current_angle || !number_of_angles) { |
1070 printerr("Passed a NULL pointer."); | 1070 printerr("Passed a NULL pointer."); |
1071 return DVDNAV_STATUS_ERR; | 1071 return DVDNAV_STATUS_ERR; |
1072 } | 1072 } |
1073 | 1073 |