Changeset 388


Ignore:
Timestamp:
04/02/08 16:01:16 (16 years ago)
Author:
r2d
Message:
  • chapters are now able to contain no tag
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libmpc/trunk/mpcchap/mpcchap.c

    r387 r388  
    106106                        tag_len += key_len + item_len;
    107107                }
    108                 tag_len += 24 + nitem * 9;
    109                 char block_size[12] = "CT";
     108                if (nitem > 0) tag_len += 24 + nitem * 9;
     109                char block_header[12] = "CT";
    110110                char sample_offset[10];
    111111                int offset_size = encodeSize(chap_pos, sample_offset, MPC_FALSE);
    112                 tag_len = encodeSize(tag_len + offset_size + 2, block_size + 2, MPC_TRUE);
    113                 fwrite(block_size, 1, tag_len + 2, in_file);
     112                tag_len = encodeSize(tag_len + offset_size + 2, block_header + 2, MPC_TRUE);
     113                fwrite(block_header, 1, tag_len + 2, in_file);
    114114                fwrite(sample_offset, 1, offset_size, in_file);
    115115                FinalizeTags(in_file, TAG_VERSION, TAG_NO_FOOTER | TAG_NO_PREAMBLE);
     
    141141
    142142        for (i = 0; i < chap_nb; i++) {
    143                 int item_count, j;
    144143                fprintf(out_file, "[%lli]\n", mpc_demux_chap(demux, i, &tag, &tag_size));
    145                 item_count = tag[8] | (tag[9] << 8) | (tag[10] << 16) | (tag[11] << 24);
    146                 tag += 24;
    147                 for( j = 0; j < item_count; j++){
    148                         int key_len = strlen(tag + 8);
    149                         int value_len = tag[0] | (tag[1] << 8) | (tag[2] << 16) | (tag[3] << 24);
    150                         fprintf(out_file, "%s=%.*s\n", tag + 8, value_len, tag + 9 + key_len);
    151                         tag += 9 + key_len + value_len;
     144                if (tag_size > 0) {
     145                        int item_count, j;
     146                        item_count = tag[8] | (tag[9] << 8) | (tag[10] << 16) | (tag[11] << 24);
     147                        tag += 24;
     148                        for( j = 0; j < item_count; j++){
     149                                int key_len = strlen(tag + 8);
     150                                int value_len = tag[0] | (tag[1] << 8) | (tag[2] << 16) | (tag[3] << 24);
     151                                fprintf(out_file, "%s=\"%.*s\"\n", tag + 8, value_len, tag + 9 + key_len);
     152                                tag += 9 + key_len + value_len;
     153                        }
    152154                }
    153155                fprintf(out_file, "\n");
Note: See TracChangeset for help on using the changeset viewer.