ifo_print.c and nav_print.c both have a function print_time. That aside
from the asserts vs. CHECK_VALUE are exactly the same. There is even a
comment about it.
So I moved print_time to a new file, dvdread_internal.c and renamed it.
Then changed the usage in {ifo,nav}_print.c to that function.
E
--
Erik Hovland
mail: [EMAIL PROTECTED]
web: http://hovland.org/
PGP/GPG public key available on request
print_time is in both files. Move it to a c file that they both can use.
From: Erik Hovland <[EMAIL PROTECTED]>
---
Makefile | 2 +-
src/Makefile.am | 2 +-
src/dvdread_internal.c | 29 +++++++++++++++++++++++++++++
src/dvdread_internal.h | 2 ++
src/ifo_print.c | 36 +++---------------------------------
src/nav_print.c | 31 ++-----------------------------
6 files changed, 38 insertions(+), 64 deletions(-)
diff --git a/Makefile b/Makefile
index 637bfd6..afcb405 100644
--- a/Makefile
+++ b/Makefile
@@ -30,7 +30,7 @@ DVDREAD_HEADERS = src/dvd_reader.h \
src/nav_types.h \
src/bitreader.h
DVDREAD_SRCS = dvd_input.c dvd_reader.c dvd_udf.c ifo_print.c ifo_read.c \
- md5.c nav_print.c nav_read.c bitreader.c
+ md5.c nav_print.c dvdread_internal.c nav_read.c bitreader.c
CFLAGS += -I$(SRC_PATH)/src
LIB = $(L).a
diff --git a/src/Makefile.am b/src/Makefile.am
index 16c814b..617bfcc 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -7,7 +7,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/src
lib_LTLIBRARIES = libdvdread.la
libdvdread_la_SOURCES = dvd_reader.c nav_read.c ifo_read.c \
- dvd_input.c dvd_udf.c md5.c nav_print.c ifo_print.c bitreader.c \
+ dvd_input.c dvd_udf.c md5.c nav_print.c ifo_print.c dvdread_internal.c bitreader.c \
bswap.h dvd_input.h dvdread_internal.h dvd_udf.h md5.h bitreader.h
libdvdread_la_LIBADD = $(DYNAMIC_LD_LIBS)
diff --git a/src/dvdread_internal.c b/src/dvdread_internal.c
new file mode 100644
index 0000000..de0e941
--- /dev/null
+++ b/src/dvdread_internal.c
@@ -0,0 +1,29 @@
+#include "ifo_types.h"
+#include "dvdread_internal.h"
+#include <stdio.h>
+
+void dvdread_print_time(dvd_time_t *dtime) {
+ const char *rate;
+ CHECK_VALUE((dtime->hour>>4) < 0xa && (dtime->hour&0xf) < 0xa);
+ CHECK_VALUE((dtime->minute>>4) < 0x7 && (dtime->minute&0xf) < 0xa);
+ CHECK_VALUE((dtime->second>>4) < 0x7 && (dtime->second&0xf) < 0xa);
+ CHECK_VALUE((dtime->frame_u&0xf) < 0xa);
+
+ printf("%02x:%02x:%02x.%02x",
+ dtime->hour,
+ dtime->minute,
+ dtime->second,
+ dtime->frame_u & 0x3f);
+ switch((dtime->frame_u & 0xc0) >> 6) {
+ case 1:
+ rate = "25.00";
+ break;
+ case 3:
+ rate = "29.97";
+ break;
+ default:
+ rate = "(please send a bug report)";
+ break;
+ }
+ printf(" @ %s fps", rate);
+}
diff --git a/src/dvdread_internal.h b/src/dvdread_internal.h
index ed9fd0f..c9cb27e 100644
--- a/src/dvdread_internal.h
+++ b/src/dvdread_internal.h
@@ -12,4 +12,6 @@
__FILE__, __LINE__, # arg ); \
}
+void dvdread_print_time(dvd_time_t *dtime);
+
#endif /* DVDREAD_INTERNAL_H */
diff --git a/src/ifo_print.c b/src/ifo_print.c
index 4029c4a..0c9a1c6 100644
--- a/src/ifo_print.c
+++ b/src/ifo_print.c
@@ -28,37 +28,7 @@
#include "ifo_types.h"
#include "ifo_read.h"
#include "ifo_print.h"
-
-/* Put this in some other file / package? It's used in nav_print too. */
-static void ifo_print_time(int level, dvd_time_t *dtime) {
- const char *rate;
- assert((dtime->hour>>4) < 0xa && (dtime->hour&0xf) < 0xa);
- assert((dtime->minute>>4) < 0x7 && (dtime->minute&0xf) < 0xa);
- assert((dtime->second>>4) < 0x7 && (dtime->second&0xf) < 0xa);
- assert((dtime->frame_u&0xf) < 0xa);
-
- printf("%02x:%02x:%02x.%02x",
- dtime->hour,
- dtime->minute,
- dtime->second,
- dtime->frame_u & 0x3f);
- switch((dtime->frame_u & 0xc0) >> 6) {
- case 1:
- rate = "25.00";
- break;
- case 3:
- rate = "29.97";
- break;
- default:
- if(dtime->hour == 0 && dtime->minute == 0
- && dtime->second == 0 && dtime->frame_u == 0)
- rate = "no";
- else
- rate = "(please send a bug report)";
- break;
- }
- printf(" @ %s fps", rate);
-}
+#include "dvdread_internal.h"
/* Put this in some other file / package? It's used in nav_print too.
Possibly also by the vm / navigator. */
@@ -655,7 +625,7 @@ static void ifo_print_CELL_PLAYBACK(cell_playback_t *cell_playback, int nr) {
for(i=0;i<nr;i++) {
printf("Cell: %3i ", i + 1);
- ifo_print_time(5, &cell_playback[i].playback_time);
+ dvdread_print_time(&cell_playback[i].playback_time);
printf("\t");
if(cell_playback[i].block_mode || cell_playback[i].block_type) {
@@ -740,7 +710,7 @@ void ifo_print_PGC(pgc_t *pgc) {
printf("Number of Cells: %i\n", pgc->nr_of_cells);
/* Check that time is 0:0:0:0 also if nr_of_programs==0 */
printf("Playback time: ");
- ifo_print_time(5, &pgc->playback_time); printf("\n");
+ dvdread_print_time(&pgc->playback_time); printf("\n");
/* If no programs/no time then does this mean anything? */
printf("Prohibited user operations: ");
diff --git a/src/nav_print.c b/src/nav_print.c
index 842ebe4..c856761 100644
--- a/src/nav_print.c
+++ b/src/nav_print.c
@@ -32,33 +32,6 @@
#include "nav_print.h"
#include "dvdread_internal.h"
-static void print_time(dvd_time_t *dtime) {
- const char *rate;
- CHECK_VALUE((dtime->hour>>4) < 0xa && (dtime->hour&0xf) < 0xa);
- CHECK_VALUE((dtime->minute>>4) < 0x7 && (dtime->minute&0xf) < 0xa);
- CHECK_VALUE((dtime->second>>4) < 0x7 && (dtime->second&0xf) < 0xa);
- CHECK_VALUE((dtime->frame_u&0xf) < 0xa);
-
- printf("%02x:%02x:%02x.%02x",
- dtime->hour,
- dtime->minute,
- dtime->second,
- dtime->frame_u & 0x3f);
- switch((dtime->frame_u & 0xc0) >> 6) {
- case 1:
- rate = "25.00";
- break;
- case 3:
- rate = "29.97";
- break;
- default:
- rate = "(please send a bug report)";
- break;
- }
- printf(" @ %s fps", rate);
-}
-
-
static void navPrint_PCI_GI(pci_gi_t *pci_gi) {
int i;
@@ -70,7 +43,7 @@ static void navPrint_PCI_GI(pci_gi_t *pci_gi) {
printf("vobu_e_ptm 0x%08x\n", pci_gi->vobu_e_ptm);
printf("vobu_se_e_ptm 0x%08x\n", pci_gi->vobu_se_e_ptm);
printf("e_eltm ");
- print_time(&pci_gi->e_eltm);
+ dvdread_print_time(&pci_gi->e_eltm);
printf("\n");
printf("vobu_isrc \"");
@@ -201,7 +174,7 @@ static void navPrint_DSI_GI(dsi_gi_t *dsi_gi) {
printf("vobu_vob_idn 0x%04x\n", dsi_gi->vobu_vob_idn);
printf("vobu_c_idn 0x%02x\n", dsi_gi->vobu_c_idn);
printf("c_eltm ");
- print_time(&dsi_gi->c_eltm);
+ dvdread_print_time(&dsi_gi->c_eltm);
printf("\n");
}
_______________________________________________
DVDnav-discuss mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/dvdnav-discuss