- if (params->tag_count == params->tag_table_capacity) {
- unsigned newsize = params->tag_table_capacity;
- newsize = newsize ? newsize * 2 : 1;
- params->tag_table =
- realloc(params->tag_table,
- newsize * sizeof(aacenc_tag_entry_t));
- params->tag_table_capacity = newsize;
+ aacenc_param_add_itmf_entry(¶ms->tags, ch, 0, optarg,
+ strlen(optarg), 0);
+ break;
+ case OPT_SHORT_TAG:
+ case OPT_SHORT_TAG_FILE:
+ case OPT_LONG_TAG:
+ {
+ char *val;
+ size_t klen;
+ unsigned fcc = M4AF_FOURCC('-','-','-','-');
+
+ if ((val = strchr(optarg, ':')) == 0) {
+ fprintf(stderr, "invalid arg for tag\n");
+ return -1;
+ }
+ *val++ = '\0';
+ if (ch == OPT_SHORT_TAG || ch == OPT_SHORT_TAG_FILE) {
+ /*
+ * take care of U+00A9(COPYRIGHT SIGN).
+ * 1) if length of fcc is 3, we prepend '\xa9'.
+ * 2) U+00A9 becomes "\xc2\xa9" in UTF-8. Therefore
+ * we remove first '\xc2'.
+ */
+ if (optarg[0] == '\xc2')
+ ++optarg;
+ if ((klen = strlen(optarg))== 3)
+ fcc = 0xa9;
+ else if (klen != 4) {
+ fprintf(stderr, "invalid arg for tag\n");
+ return -1;
+ }
+ for (; *optarg; ++optarg)
+ fcc = ((fcc << 8) | (*optarg & 0xff));
+ }
+ aacenc_param_add_itmf_entry(¶ms->tags, fcc, optarg,
+ val, strlen(val),
+ ch == OPT_SHORT_TAG_FILE);