diff options
| author | Xiaoqing MA <[email protected]> | 2018-07-11 13:31:12 +0800 |
|---|---|---|
| committer | Xiaoqing MA <[email protected]> | 2018-07-11 13:31:12 +0800 |
| commit | f7a9db56525c435d6b4131305b1ab8d7cc15b86c (patch) | |
| tree | 1ea1097949307d3520062b62d861d036ecf5af5e | |
| parent | 72e8c76611054f86a32ae9e212ab939cddc4f7fc (diff) | |
new ed17
| -rw-r--r-- | bin/test | bin | 18192 -> 18096 bytes | |||
| -rw-r--r-- | bin/test_dir | bin | 22488 -> 22392 bytes | |||
| -rw-r--r-- | inc/vdefine.h | 26 | ||||
| -rw-r--r-- | lib/libvdefine.a | bin | 15360 -> 15176 bytes | |||
| -rw-r--r-- | src/Makefile | 3 | ||||
| -rw-r--r-- | src/libvdefine.a | bin | 15360 -> 15176 bytes | |||
| -rw-r--r-- | src/vdefine.c | 56 | ||||
| -rw-r--r-- | src/vdefine.o | bin | 14984 -> 14800 bytes | |||
| -rw-r--r-- | test/Makefile | 2 | ||||
| -rw-r--r-- | test/test | bin | 18192 -> 18096 bytes | |||
| -rw-r--r-- | test/test_dir | bin | 22488 -> 22392 bytes |
11 files changed, 50 insertions, 37 deletions
| Binary files differ diff --git a/bin/test_dir b/bin/test_dir Binary files differindex 170a591..c31057d 100644 --- a/bin/test_dir +++ b/bin/test_dir diff --git a/inc/vdefine.h b/inc/vdefine.h index 9cd812d..be6c4b6 100644 --- a/inc/vdefine.h +++ b/inc/vdefine.h @@ -17,18 +17,32 @@ extern const char *mp4_box_type_all[]; extern int count_type; -int is_mpeg_ts_each(const char *buff_each, size_t size_each, const char *buff, size_t size); +/*To find that whether the initial size bytes pointed to by buff satisfies the rules of MPEG-TS AV Container + * by supposing that its first 1 byte is sync_byte in ts header.*/ +int is_mpeg_ts_each(const char *buff, size_t size); +/*To identify whether the whole byte stream belongs to MPEG_TS container*/ int is_mpeg_ts(const char* buff, size_t size); -void *memchr_flv(const char *buff_each, size_t size_each); -int is_flv_each(const char* buff_each, size_t size_each,const char *buff); +/*Scanning the initial size bytes of the memory area pointed to by buff for the first instance of 0x08, 0x09 or 0x12*/ +void *memchr_flv(const char *buff, size_t size); +/*To find that whether the initial size bytes pointed to by buff satisfies the rules of FLV AV Container + * by supposing that its first 1 byte is TagType in FLV Tag Header.*/ +int is_flv_each(const char* buff, size_t size); +/*To identify whether the whole byte stream belongs to FLV container*/ int is_flv(const char* buff, size_t size); +/*whether all of those initial 4 bytes of the memory area pointed to by buff are number or lower case */ int is_mp4_part_boxtype(const char *buff); +/*whether one byte is number or lower case*/ int char_is_mp4(char c); -int is_mp4_part_4char(const char *buff_part); -void *memmem_mp4(const char *buff_each, size_t size_each); -int is_mp4_each(const char* buff_each, size_t size_each, const char *buff); +/*whether the initial several bytes of the memory area pointed to by buff_part is one kind of Boxtype of MP4 file*/ +int is_mp4_part_4char(const char *buff); +/*Scanning the initial size bytes of the memory area pointed to by buff for the first instance of continuous 4 bytes of number or lower case*/ +void *memmem_mp4(const char *buff, size_t size); +/*To find that whether the initial size bytes pointed to by buff satisfies the rules of MP4 AV Container + * by supposing that its first 4 byte is Boxtype in Box of MP4 file.*/ +int is_mp4_each(const char* buff, size_t size); +/*To identify whether the whole byte stream belongs to MP4 container*/ int is_mp4(const char* buff, size_t size); int AV_container_identify(const char* buff, size_t size); diff --git a/lib/libvdefine.a b/lib/libvdefine.a Binary files differindex b104e7a..f827ef3 100644 --- a/lib/libvdefine.a +++ b/lib/libvdefine.a diff --git a/src/Makefile b/src/Makefile index e41329f..8d22255 100644 --- a/src/Makefile +++ b/src/Makefile @@ -6,14 +6,13 @@ CC = gcc CFLAGS = -g LIB_PATH = ../lib INC_PATH = ../inc - all:$(TARGET) .c.o: $(CC) -c $(CFLAGS) -I$(INC_PATH) $< libvdefine.a: $(OBJS) - (rm -f $@ ;ar -r $@ $^; cp $@ $(LIB_PATH);) + (rm -rf $@; ar -r $@ $^; cp $@ $(LIB_PATH);) clean: rm -f *.o $(TARGET) diff --git a/src/libvdefine.a b/src/libvdefine.a Binary files differindex b104e7a..f827ef3 100644 --- a/src/libvdefine.a +++ b/src/libvdefine.a diff --git a/src/vdefine.c b/src/vdefine.c index a978fad..2472758 100644 --- a/src/vdefine.c +++ b/src/vdefine.c @@ -17,21 +17,21 @@ const char *mp4_box_type_all[] = { "ftyp", "pdin", "moov", "mvhd", "trak", "tkhd int count_type = sizeof(mp4_box_type_all) / sizeof(char *); -int is_mpeg_ts_each(const char *buff_each, size_t size_each, const char *buff, size_t size) +int is_mpeg_ts_each(const char *buff, size_t size) { int ret_ts_each = 0; - const char *p = buff_each; + const char *p = buff; int fit_times = 1; p += 188; size_t cont_cout_ori, cont_cout_end, cont_cout_pre, cont_cout_aft; - cont_cout_ori = htonl(*(size_t *)buff_each) & 0x0000000f; + cont_cout_ori = htonl(*(size_t *)buff) & 0x0000000f; cont_cout_pre = cont_cout_ori; - while (p < (buff_each + size_each)) + while (p < (buff + size)) { if (*p == 0x47) { - if ((p + 3) < (buff_each + size_each)) + if ((p + 3) < (buff + size)) { cont_cout_aft = htonl(*(size_t *)p) & 0x0000000f; if (cont_cout_aft == (cont_cout_pre + 1) % 16) @@ -45,13 +45,13 @@ int is_mpeg_ts_each(const char *buff_each, size_t size_each, const char *buff, s } if (fit_times > FIT_TIMES) { - size_t whole_pack_cout = size_each / 188; - if (size_each % 188 == 0) + size_t whole_pack_cout = size / 188; + if (size % 188 == 0) { whole_pack_cout--; } size_t whole_pack_bites = whole_pack_cout * 188; - const char *pack_tail = buff_each + whole_pack_bites; + const char *pack_tail = buff + whole_pack_bites; if (*pack_tail == 0x47 && *(pack_tail-188) == 0x47) { ret_ts_each = 1; @@ -89,7 +89,7 @@ int is_mpeg_ts(const char* buff, size_t size) } else { - ret_ts_each = is_mpeg_ts_each(p_each, size - (p_each - buff), buff, size); + ret_ts_each = is_mpeg_ts_each(p_each, size - (p_each - buff)); if (ret_ts_each == 1) { ret_ts = 1; @@ -102,11 +102,11 @@ int is_mpeg_ts(const char* buff, size_t size) } -void *memchr_flv(const char *buff_each, size_t size_each) +void *memchr_flv(const char *buff, size_t size) { void *ret_memflv = NULL; - const char *p = buff_each; - while (p < buff_each + size_each) + const char *p = buff; + while (p < buff + size) { if (*p == 0x08 || *p == 0x09 || *p == 0x12) { @@ -118,16 +118,16 @@ void *memchr_flv(const char *buff_each, size_t size_each) return ret_memflv; } -int is_flv_each(const char* buff_each, size_t size_each, const char *buff) +int is_flv_each(const char* buff, size_t size) { int ret_flv_each = 0; - const char *p = buff_each; + const char *p = buff; int fit_times = 1; size_t left; size_t right = 11 + htonl(*(size_t *)p) & 0x00ffffff; p += (right + 4); - while (p < (buff_each + size_each)) + while (p < (buff + size)) { left = htonl(*(size_t *)(p - 4)); if (right==left&&(*(p) == 0x08 || *(p) == 0x09 || *(p) == 0x12)) @@ -143,7 +143,7 @@ int is_flv_each(const char* buff_each, size_t size_each, const char *buff) { break; } - if ((p + 3) >= (buff_each + size_each)) + if ((p + 3) >= (buff + size)) { break; } @@ -172,7 +172,7 @@ int is_flv(const char* buff, size_t size) } else { - ret_flv_each = is_flv_each(p_each, size - (p_each - buff),buff); + ret_flv_each = is_flv_each(p_each, size - (p_each - buff)); if (ret_flv_each == 1) { ret_flv = 1; @@ -211,21 +211,21 @@ int char_is_mp4(char c) } } -int is_mp4_part_4char(const char *buff_part) +int is_mp4_part_4char(const char *buff) { - if (char_is_mp4(*buff_part) == 1 && char_is_mp4(*(buff_part + 1)) == 1 && char_is_mp4(*(buff_part + 2)) == 1 && char_is_mp4(*(buff_part + 3)) == 1) + if (char_is_mp4(*buff) == 1 && char_is_mp4(*(buff + 1)) == 1 && char_is_mp4(*(buff + 2)) == 1 && char_is_mp4(*(buff + 3)) == 1) { return 1; } return 0; } -void *memmem_mp4(const char *buff_each, size_t size_each) +void *memmem_mp4(const char *buff, size_t size) { void *ret_memmp4 = NULL; char s; - const char *p = buff_each; - while (p + 3 < buff_each + size_each) + const char *p = buff; + while (p + 3 < buff + size) { if (is_mp4_part_4char(p) == 1) { @@ -237,22 +237,22 @@ void *memmem_mp4(const char *buff_each, size_t size_each) return ret_memmp4; } -int is_mp4_each(const char* buff_each, size_t size_each, const char *buff) +int is_mp4_each(const char* buff, size_t size) { int ret_mp4_each = 0; int ret_mp4_part_4char; int sig_boxtype = 0; - if (is_mp4_part_boxtype(buff_each) == 1) + if (is_mp4_part_boxtype(buff) == 1) { sig_boxtype = 1; } - const char *p = buff_each; + const char *p = buff; int fit_times = 1; size_t size_h; p += 8; - while (p + 4 < (buff_each + size_each)) + while (p + 4 < (buff + size)) { ret_mp4_part_4char = is_mp4_part_4char(p); if (ret_mp4_part_4char == 1) @@ -278,7 +278,7 @@ int is_mp4_each(const char* buff_each, size_t size_each, const char *buff) p -= 8; size_h = htonl(*(size_t *)(p - 4)); p += size_h; - if (p + 4 < buff_each + size_each) + if (p + 4 < buff + size) { ret_mp4_part_4char = is_mp4_part_4char(p); if (ret_mp4_part_4char == 1) @@ -328,7 +328,7 @@ int is_mp4(const char* buff, size_t size) } else { - ret_mp4_each = is_mp4_each(p_each, size - (p_each - buff), buff); + ret_mp4_each = is_mp4_each(p_each, size - (p_each - buff)); if (ret_mp4_each == 1) { ret_mp4 = 1; diff --git a/src/vdefine.o b/src/vdefine.o Binary files differindex 241274c..d6340f4 100644 --- a/src/vdefine.o +++ b/src/vdefine.o diff --git a/test/Makefile b/test/Makefile index d90aaf4..862ea60 100644 --- a/test/Makefile +++ b/test/Makefile @@ -6,7 +6,7 @@ BIN_PATH = ../bin LIB = -lvdefine TARGET = test test_dir -all:$(TARGET) +all::$(TARGET) test:test.c (rm -f $@; $(CC) -o $@ -I$(INC_PATH) $^ -L$(LIB_PATH) $(LIB); cp $@ $(BIN_PATH);) Binary files differdiff --git a/test/test_dir b/test/test_dir Binary files differindex 170a591..c31057d 100644 --- a/test/test_dir +++ b/test/test_dir |
