int id3tag_set_fieldvalue(lame_global_flags * gfp, const char *fieldvalue) { lame_internal_flags *gfc = gfp->internal_flags; if (fieldvalue && *fieldvalue) { uint32_t const frame_id = toID3v2TagId(fieldvalue); char **p = NULL; if (strlen(fieldvalue) < 5 || fieldvalue[4] != '=') { return -1; } if (frame_id != 0) { if (id3tag_set_textinfo_latin1(gfp, fieldvalue, &fieldvalue[5])) { p = (char **) realloc(gfc->tag_spec.values, sizeof(char *) * (gfc->tag_spec.num_values + 1)); if (!p) { return -1; } gfc->tag_spec.values = (char **) p; local_strdup(&gfc->tag_spec.values[gfc->tag_spec.num_values++], fieldvalue); } } gfc->tag_spec.flags |= CHANGED_FLAG; } id3tag_add_v2(gfp); return 0; }
int id3tag_set_albumart(lame_global_flags * gfp, const char *image, size_t size) { int mimetype = 0; unsigned char const *data = (unsigned char const *) image; lame_internal_flags *gfc = gfp->internal_flags; /* make sure the image size is no larger than the maximum value */ if (LAME_MAXALBUMART < size) { return -1; } /* determine MIME type from the actual image data */ if (2 < size && data[0] == 0xFF && data[1] == 0xD8) { mimetype = MIMETYPE_JPEG; } else if (4 < size && data[0] == 0x89 && strncmp((const char *) &data[1], "PNG", 3) == 0) { mimetype = MIMETYPE_PNG; } else if (4 < size && strncmp((const char *) data, "GIF8", 4) == 0) { mimetype = MIMETYPE_GIF; } else { return -1; } if (gfc->tag_spec.albumart != 0) { free(gfc->tag_spec.albumart); gfc->tag_spec.albumart = 0; gfc->tag_spec.albumart_size = 0; gfc->tag_spec.albumart_mimetype = MIMETYPE_NONE; } if (size < 1) { return 0; } gfc->tag_spec.albumart = malloc(size); if (gfc->tag_spec.albumart != 0) { memcpy(gfc->tag_spec.albumart, image, size); gfc->tag_spec.albumart_size = size; gfc->tag_spec.albumart_mimetype = mimetype; gfc->tag_spec.flags |= CHANGED_FLAG; id3tag_add_v2(gfp); } return 0; }
lame_encoder_impl_internal::lame_encoder_impl_internal() : m_Lame(details::dt_create_lame_encoder()), m_TotalSamplesEncoded(0) { id3tag_add_v2(m_Lame.get()); }
static gint mp3_open(void) { int imp3; gfp = lame_init(); if (gfp == NULL) return 0; /* setup id3 data */ id3tag_init(gfp); if (tuple) { /* XXX write UTF-8 even though libmp3lame does id3v2.3. --yaz */ lameid3.track_name = tuple_get_str (tuple, FIELD_TITLE, NULL); id3tag_set_title(gfp, lameid3.track_name); lameid3.performer = tuple_get_str (tuple, FIELD_ARTIST, NULL); id3tag_set_artist(gfp, lameid3.performer); lameid3.album_name = tuple_get_str (tuple, FIELD_ALBUM, NULL); id3tag_set_album(gfp, lameid3.album_name); lameid3.genre = tuple_get_str (tuple, FIELD_GENRE, NULL); id3tag_set_genre(gfp, lameid3.genre); lameid3.year = str_printf ("%d", tuple_get_int (tuple, FIELD_YEAR, NULL)); id3tag_set_year(gfp, lameid3.year); lameid3.track_number = str_printf ("%d", tuple_get_int (tuple, FIELD_TRACK_NUMBER, NULL)); id3tag_set_track(gfp, lameid3.track_number); if (force_v2_val) { id3tag_add_v2(gfp); } if (only_v1_val) { id3tag_v1_only(gfp); } if (only_v2_val) { id3tag_v2_only(gfp); } } /* input stream description */ lame_set_in_samplerate(gfp, input.frequency); lame_set_num_channels(gfp, input.channels); /* Maybe implement this? */ /* lame_set_scale(lame_global_flags *, float); */ lame_set_out_samplerate(gfp, out_samplerate_val); /* general control parameters */ lame_set_bWriteVbrTag(gfp, toggle_xing_val); lame_set_quality(gfp, algo_quality_val); if (audio_mode_val != 4) { AUDDBG("set mode to %d\n", audio_mode_val); lame_set_mode(gfp, audio_mode_val); } lame_set_errorf(gfp, lame_debugf); lame_set_debugf(gfp, lame_debugf); lame_set_msgf(gfp, lame_debugf); if (enc_toggle_val == 0 && vbr_on == 0) lame_set_brate(gfp, bitrate_val); else if (vbr_on == 0) lame_set_compression_ratio(gfp, compression_val); /* frame params */ lame_set_copyright(gfp, mark_copyright_val); lame_set_original(gfp, mark_original_val); lame_set_error_protection(gfp, error_protect_val); lame_set_strict_ISO(gfp, enforce_iso_val); if (vbr_on != 0) { if (vbr_type == 0) lame_set_VBR(gfp, 2); else lame_set_VBR(gfp, 3); lame_set_VBR_q(gfp, vbr_quality_val); lame_set_VBR_mean_bitrate_kbps(gfp, abr_val); lame_set_VBR_min_bitrate_kbps(gfp, vbr_min_val); lame_set_VBR_max_bitrate_kbps(gfp, vbr_max_val); lame_set_VBR_hard_min(gfp, enforce_min_val); } /* not to write id3 tag automatically. */ lame_set_write_id3tag_automatic(gfp, 0); if (lame_init_params(gfp) == -1) return 0; /* write id3v2 header */ imp3 = lame_get_id3v2_tag(gfp, encbuffer, sizeof(encbuffer)); if (imp3 > 0) { write_output(encbuffer, imp3); id3v2_size = imp3; } else { id3v2_size = 0; } write_buffer = NULL; write_buffer_size = 0; return 1; }