ref: 7a0b70efa99303f71883b1bdf8543991fd11405f
parent: e7712a68c406298642b8701dba009331b02b9678
author: Jean-Marc Valin <jmvalin@jmvalin.ca>
date: Fri May 12 11:08:05 EDT 2017
Remove use of Ogg integer types
--- a/include/opusenc.h
+++ b/include/opusenc.h
@@ -32,7 +32,7 @@
extern "C" {
# endif
-#include "opus.h"
+#include <opus.h>
#ifndef OPE_EXPORT
# if defined(WIN32)
--- a/src/opus_header.c
+++ b/src/opus_header.c
@@ -69,7 +69,7 @@
int pos;
} ROPacket;
-static int write_uint32(Packet *p, ogg_uint32_t val)
+static int write_uint32(Packet *p, opus_uint32 val)
{
if (p->pos>p->maxlen-4)
return 0;
@@ -81,7 +81,7 @@
return 1;
}
-static int write_uint16(Packet *p, ogg_uint16_t val)
+static int write_uint16(Packet *p, opus_uint16 val)
{
if (p->pos>p->maxlen-2)
return 0;
--- a/src/opus_header.h
+++ b/src/opus_header.h
@@ -29,13 +29,13 @@
#define OPUS_HEADER_H
#include <stdlib.h>
-#include <ogg/ogg.h>
+#include <opus.h>
typedef struct {
int version;
int channels; /* Number of channels: 1..255 */
int preskip;
- ogg_uint32_t input_sample_rate;
+ opus_uint32 input_sample_rate;
int gain; /* in dB S7.8 should be zero whenever possible */
int channel_mapping;
/* The rest is only used if channel_mapping != 0 */
--- a/src/opusenc.c
+++ b/src/opusenc.c
@@ -38,6 +38,7 @@
#include <stdio.h>
#include <string.h>
#include <assert.h>
+#include <ogg/ogg.h>
#include <opus_multistream.h>
#include "opusenc.h"
#include "opus_header.h"
@@ -161,8 +162,8 @@
int seen_file_icons;
int close_at_end;
int header_is_frozen;
- ogg_int64_t end_granule;
- ogg_int64_t granule_offset;
+ opus_int64 end_granule;
+ opus_int64 granule_offset;
EncStream *next;
};
@@ -181,9 +182,9 @@
int decision_delay;
int max_ogg_delay;
int global_granule_offset;
- ogg_int64_t curr_granule;
- ogg_int64_t write_granule;
- ogg_int64_t last_page_granule;
+ opus_int64 curr_granule;
+ opus_int64 write_granule;
+ opus_int64 last_page_granule;
unsigned char *chaining_keyframe;
int chaining_keyframe_length;
OpusEncCallbacks callbacks;
@@ -408,7 +409,7 @@
static void encode_buffer(OggOpusEnc *enc) {
/* Round up when converting the granule pos because the decoder will round down. */
- ogg_int64_t end_granule48k = (enc->streams->end_granule*48000 + enc->rate - 1)/enc->rate + enc->global_granule_offset;
+ opus_int64 end_granule48k = (enc->streams->end_granule*48000 + enc->rate - 1)/enc->rate + enc->global_granule_offset;
while (enc->buffer_end-enc->buffer_start > enc->frame_size + enc->decision_delay) {
int cont;
opus_int32 pred;
--- a/src/picture.c
+++ b/src/picture.c
@@ -125,14 +125,14 @@
PNG.
On failure, simply leaves its outputs unmodified.*/
void extract_png_params(const unsigned char *data, size_t data_length,
- ogg_uint32_t *width, ogg_uint32_t *height,
- ogg_uint32_t *depth, ogg_uint32_t *colors,
+ opus_uint32 *width, opus_uint32 *height,
+ opus_uint32 *depth, opus_uint32 *colors,
int *has_palette){
if(is_png(data,data_length)){
size_t offs;
offs=8;
while(data_length-offs>=12){
- ogg_uint32_t chunk_len;
+ opus_uint32 chunk_len;
chunk_len=READ_U32_BE(data+offs);
if(chunk_len>data_length-(offs+12))break;
else if(chunk_len==13&&memcmp(data+offs+4,"IHDR",4)==0){
@@ -169,8 +169,8 @@
GIF.
On failure, simply leaves its outputs unmodified.*/
void extract_gif_params(const unsigned char *data, size_t data_length,
- ogg_uint32_t *width, ogg_uint32_t *height,
- ogg_uint32_t *depth, ogg_uint32_t *colors,
+ opus_uint32 *width, opus_uint32 *height,
+ opus_uint32 *depth, opus_uint32 *colors,
int *has_palette){
if(is_gif(data,data_length)&&data_length>=14){
*width=data[6]|data[7]<<8;
@@ -187,8 +187,8 @@
JPEG.
On failure, simply leaves its outputs unmodified.*/
void extract_jpeg_params(const unsigned char *data, size_t data_length,
- ogg_uint32_t *width, ogg_uint32_t *height,
- ogg_uint32_t *depth, ogg_uint32_t *colors,
+ opus_uint32 *width, opus_uint32 *height,
+ opus_uint32 *depth, opus_uint32 *colors,
int *has_palette){
if(is_jpeg(data,data_length)){
size_t offs;
@@ -349,10 +349,10 @@
memcpy(buf+data_offset,filename,data_length);
}
else{
- ogg_uint32_t file_width;
- ogg_uint32_t file_height;
- ogg_uint32_t file_depth;
- ogg_uint32_t file_colors;
+ opus_uint32 file_width;
+ opus_uint32 file_height;
+ opus_uint32 file_depth;
+ opus_uint32 file_colors;
int has_palette;
/*Complicated case: we have a real file.
Read it in, attempt to parse the media type and image dimensions if
--- a/src/picture.h
+++ b/src/picture.h
@@ -1,7 +1,7 @@
#ifndef __PICTURE_H
#define __PICTURE_H
-#include <ogg/ogg.h>
+#include <opus.h>
typedef enum{
PIC_FORMAT_JPEG,
@@ -22,16 +22,16 @@
int is_gif(const unsigned char *buf, size_t length);
void extract_png_params(const unsigned char *data, size_t data_length,
- ogg_uint32_t *width, ogg_uint32_t *height,
- ogg_uint32_t *depth, ogg_uint32_t *colors,
+ opus_uint32 *width, opus_uint32 *height,
+ opus_uint32 *depth, opus_uint32 *colors,
int *has_palette);
void extract_gif_params(const unsigned char *data, size_t data_length,
- ogg_uint32_t *width, ogg_uint32_t *height,
- ogg_uint32_t *depth, ogg_uint32_t *colors,
+ opus_uint32 *width, opus_uint32 *height,
+ opus_uint32 *depth, opus_uint32 *colors,
int *has_palette);
void extract_jpeg_params(const unsigned char *data, size_t data_length,
- ogg_uint32_t *width, ogg_uint32_t *height,
- ogg_uint32_t *depth, ogg_uint32_t *colors,
+ opus_uint32 *width, opus_uint32 *height,
+ opus_uint32 *depth, opus_uint32 *colors,
int *has_palette);
char *parse_picture_specification(const char *spec,