Пример #1
0
int
id3tag_set_track(lame_global_flags * gfp, const char *track)
{
    char const *trackcount;
    lame_internal_flags *gfc = gfp->internal_flags;
    int     ret = 0;

    if (track && *track) {
        int     num = atoi(track);
        /* check for valid ID3v1 track number range */
        if (num < 1 || num > 255) {
            num = 0;
            ret = -1;   /* track number out of ID3v1 range, ignored for ID3v1 */
            gfc->tag_spec.flags |= (CHANGED_FLAG | ADD_V2_FLAG);
        }
        if (num) {
            gfc->tag_spec.track_id3v1 = num;
            gfc->tag_spec.flags |= CHANGED_FLAG;
        }
        /* Look for the total track count after a "/", same restrictions */
        trackcount = strchr(track, '/');
        if (trackcount && *trackcount) {
            gfc->tag_spec.flags |= (CHANGED_FLAG | ADD_V2_FLAG);
        }
        copyV1ToV2(gfc, ID_TRACK, track);
    }
    return ret;
}
Пример #2
0
void
id3tag_set_artist(lame_global_flags * gfp, const char *artist)
{
    lame_internal_flags *gfc = gfp->internal_flags;
    if (artist && *artist) {
        local_strdup(&gfc->tag_spec.artist, artist);
        gfc->tag_spec.flags |= CHANGED_FLAG;
        copyV1ToV2(gfc, ID_ARTIST, artist);
    }
}
Пример #3
0
void
id3tag_set_album(lame_global_flags * gfp, const char *album)
{
    lame_internal_flags *gfc = gfp->internal_flags;
    if (album && *album) {
        local_strdup(&gfc->tag_spec.album, album);
        gfc->tag_spec.flags |= CHANGED_FLAG;
        copyV1ToV2(gfc, ID_ALBUM, album);
    }
}
Пример #4
0
void
id3tag_set_title(lame_global_flags * gfp, const char *title)
{
    lame_internal_flags *gfc = gfp->internal_flags;
    if (title && *title) {
        local_strdup(&gfc->tag_spec.title, title);
        gfc->tag_spec.flags |= CHANGED_FLAG;
        copyV1ToV2(gfc, ID_TITLE, title);
    }
}
Пример #5
0
static void
id3v2AddLameVersion(lame_internal_flags * gfc)
{
    char    buffer[1024];
    const char *b = get_lame_os_bitness();
    const char *v = get_lame_version();
    const char *u = get_lame_url();
    const size_t lenb = strlen(b);

    if (lenb > 0) {
        sprintf(buffer, "LAME %s version %s (%s)", b, v, u);
    }
    else {
        sprintf(buffer, "LAME version %s (%s)", v, u);
    }
    copyV1ToV2(gfc, ID_ENCODER, buffer);
}
Пример #6
0
void
id3tag_set_year(lame_global_flags * gfp, const char *year)
{
    lame_internal_flags *gfc = gfp->internal_flags;
    if (year && *year) {
        int     num = atoi(year);
        if (num < 0) {
            num = 0;
        }
        /* limit a year to 4 digits so it fits in a version 1 tag */
        if (num > 9999) {
            num = 9999;
        }
        if (num) {
            gfc->tag_spec.year = num;
            gfc->tag_spec.flags |= CHANGED_FLAG;
        }
        copyV1ToV2(gfc, ID_YEAR, year);
    }
}
Пример #7
0
static void
id3v2AddAudioDuration(lame_internal_flags * gfc, double ms)
{
    SessionConfig_t const *const cfg = &gfc->cfg;
    char    buffer[1024];
    double const max_ulong = MAX_U_32_NUM;
    unsigned long playlength_ms;

    ms *= 1000;
    ms /= cfg->samplerate_in;
    if (ms > max_ulong) {
        playlength_ms = max_ulong;
    }
    else if (ms < 0) {
        playlength_ms = 0;
    }
    else {
        playlength_ms = ms;
    }
    sprintf(buffer, "%lu", playlength_ms);
    copyV1ToV2(gfc, ID_PLAYLENGTH, buffer);
}
Пример #8
0
int
id3tag_set_genre(lame_global_flags * gfp, const char *genre)
{
    lame_internal_flags *gfc = gfp->internal_flags;
    int     ret = 0;
    if (genre && *genre) {
        char   *str;
        int     num = strtol(genre, &str, 10);
        /* is the input a string or a valid number? */
        if (*str) {
            num = searchGenre(genre);
            if (num == GENRE_NAME_COUNT) {
                num = sloppySearchGenre(genre);
            }
            if (num == GENRE_NAME_COUNT) {
                num = GENRE_INDEX_OTHER;
                ret = -2;
            }
            else {
                genre = genre_names[num];
            }
        }
        else {
            if ((num < 0) || (num >= GENRE_NAME_COUNT)) {
                return -1;
            }
            genre = genre_names[num];
        }
        gfc->tag_spec.genre_id3v1 = num;
        gfc->tag_spec.flags |= CHANGED_FLAG;
        if (ret) {
            gfc->tag_spec.flags |= ADD_V2_FLAG;
        }
        copyV1ToV2(gfc, ID_GENRE, genre);
    }
    return ret;
}
static void
id3v2AddAudioDuration(lame_global_flags * gfp)
{
    if (gfp->num_samples != MAX_U_32_NUM) {
        char    buffer[1024];
        double const max_ulong = MAX_U_32_NUM;
        double  ms = gfp->num_samples;
        unsigned long playlength_ms;

        ms *= 1000;
        ms /= gfp->in_samplerate;
        if (ms > max_ulong) {
            playlength_ms = max_ulong;
        }
        else if (ms < 0) {
            playlength_ms = 0;
        }
        else {
            playlength_ms = ms;
        }
        snprintf(buffer, sizeof(buffer), "%lu", playlength_ms);
        copyV1ToV2(gfp, ID_PLAYLENGTH, buffer);
    }
}