mirror of
https://github.com/panzi/mediaextract
synced 2025-02-20 06:36:57 +00:00
bugfix for big-endian systems
This commit is contained in:
parent
509e151ff9
commit
01aa900a4d
2
Makefile
2
Makefile
@ -1,7 +1,7 @@
|
||||
BUILDDIR=build
|
||||
OBJ=$(BUILDDIR)/audioextract.o $(BUILDDIR)/wave.o $(BUILDDIR)/ogg.o $(BUILDDIR)/mpeg.o $(BUILDDIR)/id3.o
|
||||
CC=gcc
|
||||
CFLAGS=-Wall -std=c99 -O2 -fmessage-length=0 -g
|
||||
CFLAGS=-Wall -std=gnu99 -O2 -fmessage-length=0 -g
|
||||
BIN=$(BUILDDIR)/audioextract
|
||||
|
||||
.PHONY: all clean
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/mman.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#if (defined(_WIN16) || defined(_WIN32) || defined(_WIN64)) && !defined(__WINDOWS__)
|
||||
#define __WINDOWS__
|
||||
|
36
wave.c
36
wave.c
@ -1,3 +1,19 @@
|
||||
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
|
||||
# include <sys/endian.h>
|
||||
# define le32toh letoh32
|
||||
# define be32toh betoh32
|
||||
|
||||
#elif defined(__OpenBSD__)
|
||||
|
||||
# include <sys/endian.h>
|
||||
|
||||
#else
|
||||
|
||||
# include <endian.h>
|
||||
|
||||
#endif
|
||||
|
||||
#include "wave.h"
|
||||
|
||||
int wave_ischunk(const unsigned char *start, const unsigned char *end, size_t *lengthptr)
|
||||
@ -6,18 +22,18 @@ int wave_ischunk(const unsigned char *start, const unsigned char *end, size_t *l
|
||||
|
||||
if (end <= (unsigned char *)WAVE_HEADER_SIZE || end - WAVE_HEADER_SIZE < start)
|
||||
return 0;
|
||||
|
||||
|
||||
if (*(const int32_t *)start != RIFF_MAGIC)
|
||||
return 0;
|
||||
|
||||
length = *(const uint32_t *)(start + 4) + 8;
|
||||
|
||||
length = le32toh(*(const uint32_t *)(start + 4)) + 8;
|
||||
|
||||
if (end <= (unsigned char *)length || end - length < start)
|
||||
return 0;
|
||||
|
||||
|
||||
if (*(const uint32_t *)(start + 8) != WAVE_MAGIC)
|
||||
return 0;
|
||||
|
||||
|
||||
if (lengthptr)
|
||||
*lengthptr = length;
|
||||
|
||||
@ -31,19 +47,19 @@ int aiff_ischunk(const unsigned char *start, const unsigned char *end, size_t *l
|
||||
|
||||
if (end <= (unsigned char *)WAVE_HEADER_SIZE || end - WAVE_HEADER_SIZE < start)
|
||||
return 0;
|
||||
|
||||
|
||||
if (*(const int32_t *)start != FORM_MAGIC)
|
||||
return 0;
|
||||
|
||||
length = ntohl(*(const uint32_t *)(start + 4)) + 8;
|
||||
|
||||
length = be32toh(*(const uint32_t *)(start + 4)) + 8;
|
||||
|
||||
if (end <= (unsigned char *)length || end - length < start)
|
||||
return 0;
|
||||
|
||||
|
||||
format = *(const uint32_t *)(start + 8);
|
||||
if (format != AIFF_MAGIC && format != AIFC_MAGIC)
|
||||
return 0;
|
||||
|
||||
|
||||
if (lengthptr)
|
||||
*lengthptr = length;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user