]> git.tue.mpg.de Git - paraslash.git/commitdiff
Rename instances of struct afh_info from "afi" to "afhi".
authorAndre Noll <maan@systemlinux.org>
Fri, 26 Oct 2007 00:54:17 +0000 (02:54 +0200)
committerAndre Noll <maan@systemlinux.org>
Fri, 26 Oct 2007 00:54:17 +0000 (02:54 +0200)
aac_afh.c
afh.h
mp3_afh.c
ogg_afh.c

index f679af29de6e54efe0d1fd6dbef94eab61314a30..e495bf1484c7b832ffba01a36f8e3718092f2153 100644 (file)
--- a/aac_afh.c
+++ b/aac_afh.c
@@ -42,7 +42,7 @@ static int aac_find_stsz(unsigned char *buf, size_t buflen, off_t *skip)
        return -E_STSZ;
 }
 
-static ssize_t aac_compute_chunk_table(struct afh_info *afi,
+static ssize_t aac_compute_chunk_table(struct afh_info *afhi,
                unsigned char *map, size_t numbytes)
 {
        int ret, i;
@@ -52,37 +52,37 @@ static ssize_t aac_compute_chunk_table(struct afh_info *afi,
        ret = aac_find_stsz(map, numbytes, &skip);
        if (ret < 0)
                return ret;
-       afi->chunks_total = ret;
-       PARA_DEBUG_LOG("sz table has %lu entries\n", afi->chunks_total);
-       afi->chunk_table = para_malloc((afi->chunks_total + 1) * sizeof(size_t));
-       for (i = 1; i <= afi->chunks_total; i++) {
+       afhi->chunks_total = ret;
+       PARA_DEBUG_LOG("sz table has %lu entries\n", afhi->chunks_total);
+       afhi->chunk_table = para_malloc((afhi->chunks_total + 1) * sizeof(size_t));
+       for (i = 1; i <= afhi->chunks_total; i++) {
                if (skip + 4 > numbytes)
                        break;
                sum += aac_read_int32(map + skip);
-               afi->chunk_table[i] = sum;
+               afhi->chunk_table[i] = sum;
                skip += 4;
-//             if (i < 10 || i + 10 > afi->chunks_total)
-//                     PARA_DEBUG_LOG("offset #%d: %zu\n", i, afi->chunk_table[i]);
+//             if (i < 10 || i + 10 > afhi->chunks_total)
+//                     PARA_DEBUG_LOG("offset #%d: %zu\n", i, afhi->chunk_table[i]);
        }
        return skip;
 }
 
-static int aac_set_chunk_tv(struct afh_info *afi,
+static int aac_set_chunk_tv(struct afh_info *afhi,
                mp4AudioSpecificConfig *mp4ASC, long unsigned *seconds)
 {
        float tmp = mp4ASC->sbr_present_flag == 1? 2047 : 1023;
        struct timeval total;
-       long unsigned ms = 1000.0 * afi->chunks_total * tmp
+       long unsigned ms = 1000.0 * afhi->chunks_total * tmp
                / mp4ASC->samplingFrequency;
 
        if (!mp4ASC->samplingFrequency)
                return -E_MP4ASC;
-       ms = 1000.0 * afi->chunks_total * tmp / mp4ASC->samplingFrequency;
+       ms = 1000.0 * afhi->chunks_total * tmp / mp4ASC->samplingFrequency;
        ms2tv(ms, &total);
-       tv_divide(afi->chunks_total, &total, &afi->chunk_tv);
+       tv_divide(afhi->chunks_total, &total, &afhi->chunk_tv);
        PARA_INFO_LOG("%luHz, %lus (%lu x %lums)\n",
                mp4ASC->samplingFrequency, ms / 1000,
-               afi->chunks_total, tv2ms(&afi->chunk_tv));
+               afhi->chunks_total, tv2ms(&afhi->chunk_tv));
        if (ms < 1000)
                return -E_MP4ASC;
        *seconds = ms / 1000;
@@ -93,7 +93,7 @@ static int aac_set_chunk_tv(struct afh_info *afi,
  * Init m4a file and write some tech data to given pointers.
  */
 static int aac_get_file_info(char *map, size_t numbytes,
-               struct afh_info *afi)
+               struct afh_info *afhi)
 {
        int i;
        size_t skip;
@@ -119,32 +119,32 @@ static int aac_get_file_info(char *map, size_t numbytes,
                goto out;
        if (!mp4ASC.samplingFrequency)
                goto out;
-       ret = aac_compute_chunk_table(afi, umap, numbytes);
+       ret = aac_compute_chunk_table(afhi, umap, numbytes);
        if (ret < 0)
                goto out;
        skip = ret;
-       ret = aac_set_chunk_tv(afi, &mp4ASC, &afi->seconds_total);
+       ret = aac_set_chunk_tv(afhi, &mp4ASC, &afhi->seconds_total);
        if (ret < 0)
                goto out;
        ret = aac_find_entry_point(umap + skip, numbytes - skip, &skip);
        if (ret < 0)
                goto out;
-       afi->chunk_table[0] = ret;
-       for (i = 1; i<= afi->chunks_total; i++)
-               afi->chunk_table[i] += ret;
-       afi->channels = channels;
-       afi->frequency = rate;
-       ret = (afi->chunk_table[afi->chunks_total] - afi->chunk_table[0]) * 8; /* bits */
-       ret += (channels * afi->seconds_total * 500); /* avoid rounding error */
-       afi->bitrate = ret / (channels * afi->seconds_total * 1000);
-       sprintf(afi->info_string, "audio_file_info1:%lu x %lums, "
+       afhi->chunk_table[0] = ret;
+       for (i = 1; i<= afhi->chunks_total; i++)
+               afhi->chunk_table[i] += ret;
+       afhi->channels = channels;
+       afhi->frequency = rate;
+       ret = (afhi->chunk_table[afhi->chunks_total] - afhi->chunk_table[0]) * 8; /* bits */
+       ret += (channels * afhi->seconds_total * 500); /* avoid rounding error */
+       afhi->bitrate = ret / (channels * afhi->seconds_total * 1000);
+       sprintf(afhi->info_string, "audio_file_info1:%lu x %lums, "
                "%uHz, %d channel%s, %ukb/s\n"
                "audio_file_info2:\n"
                "audio_file_info3:\n",
-               afi->chunks_total, tv2ms(&afi->chunk_tv),
-               afi->frequency, channels, channels == 1? "" : "s", afi->bitrate
+               afhi->chunks_total, tv2ms(&afhi->chunk_tv),
+               afhi->frequency, channels, channels == 1? "" : "s", afhi->bitrate
        );
-       tv_scale(20, &afi->chunk_tv, &afi->eof_tv);
+       tv_scale(20, &afhi->chunk_tv, &afhi->eof_tv);
        ret = 1;
 out:
        if (handle)
diff --git a/afh.h b/afh.h
index 52d50a9103c8093a840c9b8e09003ad764f69c1f..1e37c9c39c26a328c6663e8108f9ff2d071ff4a2 100644 (file)
--- a/afh.h
+++ b/afh.h
 /** size of the  audio_file info string */
 #define AUDIO_FILE_INFO_SIZE 256
 
-/**
- * Audio format dependent information. Details vary between each audio format
- * handler.
- */
+/** Audio format dependent information. */
 struct afh_info {
        /** The number of chunks this audio file contains. */
        long unsigned chunks_total;
index df7b85ee790905e2446f05feac534040e83fdf45..ed55d7c02e7a7c50f1b7bc8ca4af950d2eed09b2 100644 (file)
--- a/mp3_afh.c
+++ b/mp3_afh.c
@@ -134,19 +134,19 @@ static int frame_length(struct mp3header *header)
                + header->padding;
 }
 
-static void write_info_str(struct afh_info *afi)
+static void write_info_str(struct afh_info *afhi)
 {
        int v = mp3.id3_isvalid;
 
-       snprintf(afi->info_string, MMD_INFO_SIZE,
+       snprintf(afhi->info_string, MMD_INFO_SIZE,
                "audio_file_info1:%lu x %lums, %u kbit/s (%cbr) %i KHz %s\n"
                "audio_file_info2:%s, by %s\n"
                "audio_file_info3:A: %s, Y: %s, C: %s\n",
-               afi->chunks_total,
-               tv2ms(&afi->chunk_tv),
-               afi->bitrate,
+               afhi->chunks_total,
+               tv2ms(&afhi->chunk_tv),
+               afhi->bitrate,
                mp3.vbr? 'v' : 'c',
-               afi->frequency / 1000,
+               afhi->frequency / 1000,
                header_mode(&mp3.header),
                v && *mp3.id3.title? mp3.id3.title : "(title tag not set)",
                v && *mp3.id3.artist? mp3.id3.artist : "(artist tag not set)",
@@ -317,7 +317,7 @@ static int find_valid_start(unsigned char *map, size_t numbytes, off_t *fpos)
 }
 
 static int mp3_read_info(unsigned char *map, size_t numbytes,
-               struct afh_info *afi)
+               struct afh_info *afhi)
 {
        long fl_avg = 0, freq_avg = 0, br_avg = 0;
        int ret, len = 0, old_br = -1;
@@ -325,8 +325,8 @@ static int mp3_read_info(unsigned char *map, size_t numbytes,
        unsigned chunk_table_size = 1000; /* gets increased on demand */
        off_t fpos = 0;
 
-       afi->chunks_total = 0;
-       afi->chunk_table = para_malloc(chunk_table_size * sizeof(size_t));
+       afhi->chunks_total = 0;
+       afhi->chunk_table = para_malloc(chunk_table_size * sizeof(size_t));
        mp3_get_id3(map, numbytes, &fpos);
        fpos = 0;
        mp3.vbr = 0;
@@ -355,47 +355,47 @@ static int mp3_read_info(unsigned char *map, size_t numbytes,
                tv_add(&cct, &total_time, &tmp);
                total_time = tmp;
                //PARA_DEBUG_LOG("%s: br: %d, freq: %d, fl: %d, cct: %lu\n", __func__, br, freq, fl, cct.tv_usec);
-               if (afi->chunks_total >= chunk_table_size) {
+               if (afhi->chunks_total >= chunk_table_size) {
                        chunk_table_size *= 2;
-                       afi->chunk_table = para_realloc(afi->chunk_table,
+                       afhi->chunk_table = para_realloc(afhi->chunk_table,
                                chunk_table_size * sizeof(size_t));
                }
-               afi->chunk_table[afi->chunks_total] = fpos;
-//             if (afi->chunks_total < 10 || !(afi->chunks_total % 1000))
-//                     PARA_INFO_LOG("chunk #%lu: %zd\n", afi->chunks_total,
-//                             afi->chunk_table[afi->chunks_total]);
-               afi->chunks_total++;
-               if (afi->chunks_total == 1) {
+               afhi->chunk_table[afhi->chunks_total] = fpos;
+//             if (afhi->chunks_total < 10 || !(afhi->chunks_total % 1000))
+//                     PARA_INFO_LOG("chunk #%lu: %zd\n", afhi->chunks_total,
+//                             afhi->chunk_table[afhi->chunks_total]);
+               afhi->chunks_total++;
+               if (afhi->chunks_total == 1) {
                        freq_avg = freq;
                        br_avg = br;
                        old_br = br;
                        fl_avg = fl;
                        continue;
                }
-               freq_avg += ((long)freq - freq_avg) / ((long)afi->chunks_total + 1);
-               fl_avg += ((long)fl - fl_avg) / ((long)afi->chunks_total + 1);
-               br_avg += ((long)br - br_avg) / ((long)afi->chunks_total + 1);
+               freq_avg += ((long)freq - freq_avg) / ((long)afhi->chunks_total + 1);
+               fl_avg += ((long)fl - fl_avg) / ((long)afhi->chunks_total + 1);
+               br_avg += ((long)br - br_avg) / ((long)afhi->chunks_total + 1);
                if (old_br != br)
                        mp3.vbr = 1;
                old_br = br;
        }
        ret = -E_MP3_INFO;
-       if (!afi->chunks_total || !freq_avg || !br_avg)
+       if (!afhi->chunks_total || !freq_avg || !br_avg)
                goto err_out;
-       afi->chunk_table[afi->chunks_total] = numbytes - 1;
-       afi->bitrate = br_avg;
-       afi->frequency = freq_avg;
-       afi->channels = header_channels(&mp3.header);
-       afi->seconds_total = (tv2ms(&total_time) + 500) / 1000;
-       tv_divide(afi->chunks_total, &total_time, &afi->chunk_tv);
-       PARA_DEBUG_LOG("%lu chunks, each %lums\n", afi->chunks_total,
-               tv2ms(&afi->chunk_tv));
-       tv_scale(3, &afi->chunk_tv, &afi->eof_tv);
-       PARA_DEBUG_LOG("eof timeout: %lu\n", tv2ms(&afi->eof_tv));
+       afhi->chunk_table[afhi->chunks_total] = numbytes - 1;
+       afhi->bitrate = br_avg;
+       afhi->frequency = freq_avg;
+       afhi->channels = header_channels(&mp3.header);
+       afhi->seconds_total = (tv2ms(&total_time) + 500) / 1000;
+       tv_divide(afhi->chunks_total, &total_time, &afhi->chunk_tv);
+       PARA_DEBUG_LOG("%lu chunks, each %lums\n", afhi->chunks_total,
+               tv2ms(&afhi->chunk_tv));
+       tv_scale(3, &afhi->chunk_tv, &afhi->eof_tv);
+       PARA_DEBUG_LOG("eof timeout: %lu\n", tv2ms(&afhi->eof_tv));
        return 1;
 err_out:
        PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret));
-       free(afi->chunk_table);
+       free(afhi->chunk_table);
        return ret;
 }
 
@@ -403,15 +403,15 @@ err_out:
  * Read mp3 information from audio file
  */
 int mp3_get_file_info(char *map, size_t numbytes,
-               struct afh_info *afi)
+               struct afh_info *afhi)
 {
        int ret;
 
-       ret = mp3_read_info((unsigned char *)map, numbytes, afi);
+       ret = mp3_read_info((unsigned char *)map, numbytes, afhi);
        if (ret < 0)
                return ret;
-       write_info_str(afi);
-       if (afi->seconds_total < 2 || !afi->chunks_total)
+       write_info_str(afhi);
+       if (afhi->seconds_total < 2 || !afhi->chunks_total)
                return -E_MP3_INFO;
        return 1;
 }
index f4f375cbea76480de87838612569eaf47cd9f658..5611579abd552df3b6074a2cf4d65abb1b3abab1 100644 (file)
--- a/ogg_afh.c
+++ b/ogg_afh.c
@@ -112,7 +112,7 @@ static int ogg_open_callbacks(void *datasource, OggVorbis_File *vf, ov_callbacks
 }
 
 static int ogg_compute_header_len(char *map, size_t numbytes,
-               struct afh_info *afi)
+               struct afh_info *afhi)
 {
        int ret;
        size_t len = PARA_MIN(numbytes, CHUNK_SIZE);
@@ -176,11 +176,11 @@ static int ogg_compute_header_len(char *map, size_t numbytes,
        ogg_stream_packetout(stream_in, &packet);
        ogg_stream_packetin(stream_out, &packet);
 
-       afi->header_len = 0;
+       afhi->header_len = 0;
        while (ogg_stream_flush(stream_out, &page))
-               afi->header_len += page.body_len + page.header_len;
-       PARA_DEBUG_LOG("header_len = %d\n", afi->header_len);
-       afi->header_offset = 0;
+               afhi->header_len += page.body_len + page.header_len;
+       PARA_DEBUG_LOG("header_len = %d\n", afhi->header_len);
+       afhi->header_offset = 0;
        ret = 1;
 err2:
        ogg_stream_destroy(stream_in);
@@ -198,7 +198,7 @@ err1:
  * CHUNK_TIME begins. Always successful.
  */
 static long unsigned ogg_compute_chunk_table(OggVorbis_File *of,
-       struct afh_info *afi, long unsigned time_total)
+       struct afh_info *afhi, long unsigned time_total)
 {
        int i, ret, num;
        ssize_t max_chunk_len, pos = 0, min = 0, old_pos;
@@ -209,8 +209,8 @@ static long unsigned ogg_compute_chunk_table(OggVorbis_File *of,
        num = time_total / chunk_time + 3;
        PARA_DEBUG_LOG("chunk time: %g allocating %d chunk pointers\n",
                chunk_time, num);
-       afi->chunk_table = para_malloc((num + 1) * sizeof(size_t));
-       afi->chunk_table[0] = 0;
+       afhi->chunk_table = para_malloc((num + 1) * sizeof(size_t));
+       afhi->chunk_table[0] = 0;
        max_chunk_len = 0;
        for (i = 1; ret <= num; i++) {
                ogg_int64_t diff;
@@ -221,7 +221,7 @@ static long unsigned ogg_compute_chunk_table(OggVorbis_File *of,
                diff = pos - old_pos;
                max_chunk_len = PARA_MAX(max_chunk_len, diff);
                min = (i == 1)? diff : PARA_MIN(min, diff);
-               afi->chunk_table[i] = pos;
+               afhi->chunk_table[i] = pos;
 //             if (i < 11 || !((i - 1) % 1000)|| i > num - 11)
 //                     PARA_DEBUG_LOG("chunk #%d: %g secs, pos: %zd, "
 //                             "size: %zd\n", i - 1,
@@ -239,7 +239,7 @@ static long unsigned ogg_compute_chunk_table(OggVorbis_File *of,
  * Init oggvorbis file and write some tech data to given pointers.
  */
 static int ogg_get_file_info(char *map, size_t numbytes,
-               struct afh_info *afi)
+               struct afh_info *afhi)
 {
        int ret;
        vorbis_info *vi;
@@ -252,7 +252,7 @@ static int ogg_get_file_info(char *map, size_t numbytes,
        };
        struct ogg_datasource ods = {.map = map, .numbytes = numbytes, .fpos = 0};
 
-       ret = ogg_compute_header_len(map, numbytes, afi);
+       ret = ogg_compute_header_len(map, numbytes, afhi);
        if (ret < 0)
                return ret;
        ret = ogg_open_callbacks(&ods, &of, ovc);
@@ -262,21 +262,21 @@ static int ogg_get_file_info(char *map, size_t numbytes,
        vi = ov_info(&of, 0);
        if (!vi)
                goto err;
-       afi->seconds_total = ov_time_total(&of, -1);
-       afi->frequency = vi->rate;
-       afi->bitrate = ov_bitrate(&of, 0) / 1000;
-       afi->channels = vi->channels;
-       afi->chunks_total = ogg_compute_chunk_table(&of, afi, afi->seconds_total);
-       sprintf(afi->info_string, "audio_file_info1:%lu x %lu, %ukHz, "
+       afhi->seconds_total = ov_time_total(&of, -1);
+       afhi->frequency = vi->rate;
+       afhi->bitrate = ov_bitrate(&of, 0) / 1000;
+       afhi->channels = vi->channels;
+       afhi->chunks_total = ogg_compute_chunk_table(&of, afhi, afhi->seconds_total);
+       sprintf(afhi->info_string, "audio_file_info1:%lu x %lu, %ukHz, "
                "%d channels, %ukbps\n"
                "audio_file_info2: \n"
                "audio_file_info3: \n",
-               afi->chunks_total, (long unsigned) (chunk_time * 1000 * 1000),
-               afi->frequency / 1000, vi->channels, afi->bitrate
+               afhi->chunks_total, (long unsigned) (chunk_time * 1000 * 1000),
+               afhi->frequency / 1000, vi->channels, afhi->bitrate
                );
-       afi->chunk_tv.tv_sec = 0;
-       afi->chunk_tv.tv_usec = 250 * 1000;
-       tv_scale(3, &afi->chunk_tv, &afi->eof_tv);
+       afhi->chunk_tv.tv_sec = 0;
+       afhi->chunk_tv.tv_usec = 250 * 1000;
+       tv_scale(3, &afhi->chunk_tv, &afhi->eof_tv);
        ret = 1;
 err:
        ov_clear(&of); /* keeps the file open */