-
Notifications
You must be signed in to change notification settings - Fork 5
/
dvd_vob.c
53 lines (36 loc) · 1.26 KB
/
dvd_vob.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "dvd_vob.h"
/**
* Functions used to get information about a DVD VOB
*/
uint64_t dvd_vob_blocks(dvd_reader_t *dvdread_dvd, uint16_t vts_number, uint16_t vob_number) {
uint64_t vob_blocks = 0;
ssize_t vob_filesize = 0;
vob_filesize = dvd_vob_filesize(dvdread_dvd, vts_number, vob_number);
if(vob_filesize > 0)
vob_blocks = (uint64_t)(vob_filesize / DVD_VIDEO_LB_LEN);
return vob_blocks;
}
ssize_t dvd_vob_filesize(dvd_reader_t *dvdread_dvd, uint16_t vts_number, uint16_t vob_number) {
dvd_stat_t dvdread_stat;
ssize_t vob_filesize = 0;
int retval = -1;
if(vob_number == 0) {
retval = DVDFileStat(dvdread_dvd, vts_number, DVD_READ_MENU_VOBS, &dvdread_stat);
if(retval == 0)
vob_filesize = dvdread_stat.parts_size[0];
} else {
retval = DVDFileStat(dvdread_dvd, vts_number, DVD_READ_TITLE_VOBS, &dvdread_stat);
if(retval == 0)
vob_filesize = dvdread_stat.parts_size[vob_number - 1];
}
return vob_filesize;
}
double dvd_vob_filesize_mbs(dvd_reader_t *dvdread_dvd, uint16_t vts_number, uint16_t vob_number) {
uint64_t blocks;
blocks = dvd_vob_blocks(dvdread_dvd, vts_number, vob_number);
if(blocks == 0)
return 0;
double vob_filesize_mbs = 0;
vob_filesize_mbs = ceil((blocks * DVD_VIDEO_LB_LEN) / 1048576.0);
return vob_filesize_mbs;
}