shithub: libopusenc

Download patch

ref: bc936c3d7110db98c658a50fd6a8cf7690f73ffa
parent: 651de26273d638159cdc83d8f2d4958f1d3aeb80
author: Mark Harris <mark.hsj@gmail.com>
date: Wed Sep 12 19:30:41 EDT 2018

Avoid reserved identifiers for macros/functions

--- a/include/opusenc.h
+++ b/include/opusenc.h
@@ -24,8 +24,8 @@
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-#if !defined(_opusenc_h)
-# define _opusenc_h (1)
+#ifndef OPUSENC_H
+# define OPUSENC_H
 
 /**\mainpage
    \section Introduction
--- a/src/ogg_packer.h
+++ b/src/ogg_packer.h
@@ -24,8 +24,8 @@
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-#if !defined(_oggpacker_h)
-# define _oggpacker_h (1)
+#ifndef OGGPACKER_H
+# define OGGPACKER_H
 
 
 # if defined(__cplusplus)
--- a/src/opus_header.c
+++ b/src/opus_header.c
@@ -118,7 +118,7 @@
 #endif
 }
 
-int _ope_opus_header_get_size(const OpusHeader *h)
+int opeint_opus_header_get_size(const OpusHeader *h)
 {
   int len=0;
   if (opeint_use_projection(h->channel_mapping))
@@ -141,7 +141,7 @@
   return len;
 }
 
-int _ope_opus_header_to_packet(const OpusHeader *h, unsigned char *packet, int len, const OpusGenericEncoder *st)
+int opeint_opus_header_to_packet(const OpusHeader *h, unsigned char *packet, int len, const OpusGenericEncoder *st)
 {
    int i;
    Packet p;
@@ -248,7 +248,7 @@
                                      buf[base]=(val)&0xff; \
                                  }while(0)
 
-void _ope_comment_init(char **comments, int* length, const char *vendor_string)
+void opeint_comment_init(char **comments, int* length, const char *vendor_string)
 {
   /*The 'vendor' field should be the actual encoding library used.*/
   int vendor_length=strlen(vendor_string);
@@ -267,7 +267,7 @@
   *comments=p;
 }
 
-int _ope_comment_add(char **comments, int* length, const char *tag, const char *val)
+int opeint_comment_add(char **comments, int* length, const char *tag, const char *val)
 {
   char* p=*comments;
   int vendor_length=readint(p, 8);
@@ -291,7 +291,7 @@
   return 0;
 }
 
-void _ope_comment_pad(char **comments, int* length, int amount)
+void opeint_comment_pad(char **comments, int* length, int amount)
 {
   if(amount>0){
     int i;
--- a/src/opus_header.h
+++ b/src/opus_header.h
@@ -83,14 +83,14 @@
    unsigned char stream_map[255];
 } OpusHeader;
 
-int _ope_opus_header_get_size(const OpusHeader *h);
+int opeint_opus_header_get_size(const OpusHeader *h);
 
-int _ope_opus_header_to_packet(const OpusHeader *h, unsigned char *packet, int len, const OpusGenericEncoder *st);
+int opeint_opus_header_to_packet(const OpusHeader *h, unsigned char *packet, int len, const OpusGenericEncoder *st);
 
-void _ope_comment_init(char **comments, int* length, const char *vendor_string);
+void opeint_comment_init(char **comments, int* length, const char *vendor_string);
 
-int _ope_comment_add(char **comments, int* length, const char *tag, const char *val);
+int opeint_comment_add(char **comments, int* length, const char *tag, const char *val);
 
-void _ope_comment_pad(char **comments, int* length, int amount);
+void opeint_comment_pad(char **comments, int* length, int amount);
 
 #endif
--- a/src/opusenc.c
+++ b/src/opusenc.c
@@ -87,7 +87,7 @@
   if (c == NULL) return NULL;
   libopus_str = opus_get_version_string();
   snprintf(vendor_str, sizeof(vendor_str), "%s, %s %s", libopus_str, PACKAGE_NAME, PACKAGE_VERSION);
-  _ope_comment_init(&c->comment, &c->comment_length, vendor_str);
+  opeint_comment_init(&c->comment, &c->comment_length, vendor_str);
   c->seen_file_icons = 0;
   if (c->comment == NULL) {
     free(c);
@@ -123,7 +123,7 @@
 int ope_comments_add(OggOpusComments *comments, const char *tag, const char *val) {
   if (tag == NULL || val == NULL) return OPE_BAD_ARG;
   if (strchr(tag, '=')) return OPE_BAD_ARG;
-  if (_ope_comment_add(&comments->comment, &comments->comment_length, tag, val)) return OPE_ALLOC_FAIL;
+  if (opeint_comment_add(&comments->comment, &comments->comment_length, tag, val)) return OPE_ALLOC_FAIL;
   return OPE_OK;
 }
 
@@ -130,7 +130,7 @@
 /* Add a comment. */
 int ope_comments_add_string(OggOpusComments *comments, const char *tag_and_val) {
   if (!strchr(tag_and_val, '=')) return OPE_BAD_ARG;
-  if (_ope_comment_add(&comments->comment, &comments->comment_length, NULL, tag_and_val)) return OPE_ALLOC_FAIL;
+  if (opeint_comment_add(&comments->comment, &comments->comment_length, NULL, tag_and_val)) return OPE_ALLOC_FAIL;
   return OPE_OK;
 }
 
@@ -137,11 +137,11 @@
 int ope_comments_add_picture(OggOpusComments *comments, const char *filename, int picture_type, const char *description) {
   char *picture_data;
   int err;
-  picture_data = _ope_parse_picture_specification(filename, picture_type, description, &err, &comments->seen_file_icons);
+  picture_data = opeint_parse_picture_specification(filename, picture_type, description, &err, &comments->seen_file_icons);
   if (picture_data == NULL || err != OPE_OK){
     return err;
   }
-  _ope_comment_add(&comments->comment, &comments->comment_length, "METADATA_BLOCK_PICTURE", picture_data);
+  opeint_comment_add(&comments->comment, &comments->comment_length, "METADATA_BLOCK_PICTURE", picture_data);
   free(picture_data);
   return OPE_OK;
 }
@@ -149,11 +149,11 @@
 int ope_comments_add_picture_from_memory(OggOpusComments *comments, const char *ptr, size_t size, int picture_type, const char *description) {
   char *picture_data;
   int err;
-  picture_data = _ope_parse_picture_specification_from_memory(ptr, size, picture_type, description, &err, &comments->seen_file_icons);
+  picture_data = opeint_parse_picture_specification_from_memory(ptr, size, picture_type, description, &err, &comments->seen_file_icons);
   if (picture_data == NULL || err != OPE_OK){
     return err;
   }
-  _ope_comment_add(&comments->comment, &comments->comment_length, "METADATA_BLOCK_PICTURE", picture_data);
+  opeint_comment_add(&comments->comment, &comments->comment_length, "METADATA_BLOCK_PICTURE", picture_data);
   free(picture_data);
   return OPE_OK;
 }
@@ -325,7 +325,7 @@
     free(obj);
     return NULL;
   }
-  obj->file = _ope_fopen(path, "wb");
+  obj->file = opeint_fopen(path, "wb");
   if (!obj->file) {
     if (error) *error = OPE_CANNOT_OPEN;
     ope_encoder_destroy(enc);
@@ -514,7 +514,7 @@
     }
     oggp_set_muxing_delay(enc->oggp, enc->max_ogg_delay);
   }
-  _ope_comment_pad(&enc->streams->comment, &enc->streams->comment_length, enc->comment_padding);
+  opeint_comment_pad(&enc->streams->comment, &enc->streams->comment_length, enc->comment_padding);
 
   /* Get preskip at the last minute (when it can no longer change). */
   if (enc->global_granule_offset == -1) {
@@ -531,9 +531,9 @@
     int ret;
     int packet_size;
     unsigned char *p;
-    header_size = _ope_opus_header_get_size(&enc->header);
+    header_size = opeint_opus_header_get_size(&enc->header);
     p = oggp_get_packet_buffer(enc->oggp, header_size);
-    packet_size = _ope_opus_header_to_packet(&enc->header, p, header_size, &enc->st);
+    packet_size = opeint_opus_header_to_packet(&enc->header, p, header_size, &enc->st);
     if (enc->packet_callback) enc->packet_callback(enc->packet_callback_data, p, packet_size, 0);
     oggp_commit_packet(enc->oggp, packet_size, 0, 0);
     ret = oe_flush_page(enc);
@@ -870,7 +870,7 @@
   int ret;
   struct StdioObject *obj;
   if (!(obj = malloc(sizeof(*obj)))) return OPE_ALLOC_FAIL;
-  obj->file = _ope_fopen(path, "wb");
+  obj->file = opeint_fopen(path, "wb");
   if (!obj->file) {
     free(obj);
     /* By trying to open the file first, we can recover if we can't open it. */
--- a/src/picture.c
+++ b/src/picture.c
@@ -228,13 +228,13 @@
 
 #define IMAX(a,b) ((a) > (b) ? (a) : (b))
 
-static unsigned char *_ope_read_picture_file(const char *filename, const char *description, int *error, size_t *size, size_t *offset) {
+static unsigned char *opeint_read_picture_file(const char *filename, const char *description, int *error, size_t *size, size_t *offset) {
   FILE          *picture_file;
   size_t         cbuf;
   size_t         nbuf;
   size_t         data_offset;
   unsigned char *buf;
-  picture_file=_ope_fopen(filename,"rb");
+  picture_file=opeint_fopen(filename,"rb");
   /*Buffer size: 8 static 4-byte fields plus 2 dynamic fields, plus the
      file/URL data.
     We reserve at least 10 bytes for the media type, in case we still need to
@@ -302,7 +302,7 @@
    have already been added, to ensure only one is allowed.
   Return: A Base64-encoded string suitable for use in a METADATA_BLOCK_PICTURE
    tag.*/
-static char *_ope_parse_picture_specification_impl(unsigned char *buf, size_t nbuf, size_t data_offset, int picture_type, const char *description,
+static char *opeint_parse_picture_specification_impl(unsigned char *buf, size_t nbuf, size_t data_offset, int picture_type, const char *description,
                                   int *error, int *seen_file_icons){
   opus_uint32  width;
   opus_uint32  height;
@@ -390,7 +390,7 @@
   return out;
 }
 
-char *_ope_parse_picture_specification(const char *filename, int picture_type, const char *description,
+char *opeint_parse_picture_specification(const char *filename, int picture_type, const char *description,
                                   int *error, int *seen_file_icons){
   size_t nbuf;
   size_t data_offset;
@@ -402,14 +402,14 @@
     return NULL;
   }
   if (description == NULL) description = "";
-  buf = _ope_read_picture_file(filename, description, error, &nbuf, &data_offset);
+  buf = opeint_read_picture_file(filename, description, error, &nbuf, &data_offset);
   if (buf == NULL) return NULL;
-  ret = _ope_parse_picture_specification_impl(buf, nbuf, data_offset, picture_type, description, error, seen_file_icons);
+  ret = opeint_parse_picture_specification_impl(buf, nbuf, data_offset, picture_type, description, error, seen_file_icons);
   free(buf);
   return ret;
 }
 
-char *_ope_parse_picture_specification_from_memory(const char *mem, size_t size, int picture_type, const char *description,
+char *opeint_parse_picture_specification_from_memory(const char *mem, size_t size, int picture_type, const char *description,
                                   int *error, int *seen_file_icons){
   size_t nbuf;
   size_t data_offset;
@@ -429,7 +429,7 @@
     return NULL;
   }
   memcpy(buf+data_offset, mem, size);
-  ret = _ope_parse_picture_specification_impl(buf, nbuf, data_offset, picture_type, description, error, seen_file_icons);
+  ret = opeint_parse_picture_specification_impl(buf, nbuf, data_offset, picture_type, description, error, seen_file_icons);
   free(buf);
   return ret;
 }
--- a/src/picture.h
+++ b/src/picture.h
@@ -25,8 +25,8 @@
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-#ifndef __PICTURE_H
-#define __PICTURE_H
+#ifndef PICTURE_H
+#define PICTURE_H
 
 #include <opus.h>
 #include "opusenc.h"
@@ -39,10 +39,10 @@
 
 #define BASE64_LENGTH(len) (((len)+2)/3*4)
 
-char *_ope_parse_picture_specification(const char *filename, int picture_type, const char *description,
+char *opeint_parse_picture_specification(const char *filename, int picture_type, const char *description,
                                   int *error, int *seen_file_icons);
 
-char *_ope_parse_picture_specification_from_memory(const char *mem, size_t size, int picture_type, const char *description,
+char *opeint_parse_picture_specification_from_memory(const char *mem, size_t size, int picture_type, const char *description,
                                   int *error, int *seen_file_icons);
 
 #define WRITE_U32_BE(buf, val) \
@@ -54,4 +54,4 @@
   } \
   while(0);
 
-#endif /* __PICTURE_H */
+#endif /* PICTURE_H */
--- a/src/unicode_support.c
+++ b/src/unicode_support.c
@@ -50,7 +50,7 @@
 	return ((Result > 0) && (Result <= BuffSize)) ? Buffer : NULL;
 }
 
-FILE *_ope_fopen(const char *filename_utf8, const char *mode_utf8)
+FILE *opeint_fopen(const char *filename_utf8, const char *mode_utf8)
 {
 	FILE *ret = NULL;
 	wchar_t *filename_utf16 = utf8_to_utf16(filename_utf8);
@@ -71,7 +71,7 @@
 
 #include <stdio.h>
 
-FILE *_ope_fopen(const char *filename_utf8, const char *mode_utf8) {
+FILE *opeint_fopen(const char *filename_utf8, const char *mode_utf8) {
   return fopen(filename_utf8, mode_utf8);
 }
 
--- a/src/unicode_support.h
+++ b/src/unicode_support.h
@@ -34,6 +34,6 @@
 
 #define WIN_UNICODE 1
 
-FILE *_ope_fopen(const char *filename_utf8, const char *mode_utf8);
+FILE *opeint_fopen(const char *filename_utf8, const char *mode_utf8);
 
 #endif