⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 betaplayer_0.096源码 tcpmp老版本
💻 C
📖 第 1 页 / 共 3 页
字号:
        for (k = 0; k < j; k++)        {            if (mp4ff_meta_get_by_index(infile, k, &item, &tag))            {                if (item != NULL && tag != NULL)                {                    fprintf(stderr, "%s: %s\n", item, tag);                    free(item); item = NULL;                    free(tag); tag = NULL;                }            }        }        if (j > 0) fprintf(stderr, "\n");#endif    }    if (infoOnly)    {        NeAACDecClose(hDecoder);        mp4ff_close(infile);        free(mp4cb);        fclose(mp4File);        return 0;    }    numSamples = mp4ff_num_samples(infile, track);    for (sampleId = 0; sampleId < numSamples; sampleId++)    {        int rc;        long dur;        unsigned int sample_count;        unsigned int delay = 0;        /* get acces unit from MP4 file */        buffer = NULL;        buffer_size = 0;        dur = mp4ff_get_sample_duration(infile, track, sampleId);        rc = mp4ff_read_sample(infile, track, sampleId, &buffer,  &buffer_size);        if (rc == 0)        {            fprintf(stderr, "Reading from MP4 file failed.\n");            NeAACDecClose(hDecoder);            mp4ff_close(infile);            free(mp4cb);            fclose(mp4File);            return 1;        }        sample_buffer = NeAACDecDecode(hDecoder, &frameInfo, buffer, buffer_size);        if (adts_out == 1)        {            adtsData = MakeAdtsHeader(&adtsDataSize, &frameInfo, 0);            /* write the adts header */            fwrite(adtsData, 1, adtsDataSize, adtsFile);            fwrite(buffer, 1, frameInfo.bytesconsumed, adtsFile);        }        if (buffer) free(buffer);        if (!noGapless)        {            if (sampleId == 0) dur = 0;            if (useAacLength || (timescale != samplerate)) {                sample_count = frameInfo.samples;            } else {                sample_count = (unsigned int)(dur * frameInfo.channels);                if (!useAacLength && !initial && (sampleId < numSamples/2) && (sample_count != frameInfo.samples))                {                    fprintf(stderr, "MP4 seems to have incorrect frame duration, using values from AAC data.\n");                    useAacLength = 1;                    sample_count = frameInfo.samples;                }            }            if (initial && (sample_count < framesize*frameInfo.channels) && (frameInfo.samples > sample_count))                delay = frameInfo.samples - sample_count;        } else {            sample_count = frameInfo.samples;        }        /* open the sound file now that the number of channels are known */        if (first_time && !frameInfo.error)        {            /* print some channel info */            print_channel_info(&frameInfo);            if (!adts_out)            {                /* open output file */                if(!to_stdout)                {                    aufile = open_audio_file(sndfile, frameInfo.samplerate, frameInfo.channels,                        outputFormat, fileType, aacChannelConfig2wavexChannelMask(&frameInfo));                } else {#ifdef _WIN32                    setmode(fileno(stdout), O_BINARY);#endif                    aufile = open_audio_file("-", frameInfo.samplerate, frameInfo.channels,                        outputFormat, fileType, aacChannelConfig2wavexChannelMask(&frameInfo));                }                if (aufile == NULL)                {                    NeAACDecClose(hDecoder);                    mp4ff_close(infile);                    free(mp4cb);                    fclose(mp4File);                    return 0;                }            }            first_time = 0;        }        if (sample_count > 0) initial = 0;        percent = min((int)(sampleId*100)/numSamples, 100);        if (percent > old_percent)        {            old_percent = percent;            sprintf(percents, "%d%% decoding %s.", percent, mp4file);            fprintf(stderr, "%s\r", percents);#ifdef _WIN32            SetConsoleTitle(percents);#endif        }        if ((frameInfo.error == 0) && (sample_count > 0) && (!adts_out))        {            write_audio_file(aufile, sample_buffer, sample_count, delay);        }        if (frameInfo.error > 0)        {            fprintf(stderr, "Warning: %s\n",                NeAACDecGetErrorMessage(frameInfo.error));        }    }    NeAACDecClose(hDecoder);    if (adts_out == 1)    {        fclose(adtsFile);    }    mp4ff_close(infile);    if (!first_time && !adts_out)        close_audio_file(aufile);    free(mp4cb);    fclose(mp4File);    return frameInfo.error;}int main(int argc, char *argv[]){    int result;    int infoOnly = 0;    int writeToStdio = 0;    int object_type = LC;    int def_srate = 0;    int downMatrix = 0;    int format = 1;    int outputFormat = FAAD_FMT_16BIT;    int outfile_set = 0;    int adts_out = 0;    int old_format = 0;    int showHelp = 0;    int mp4file = 0;    int noGapless = 0;    char *fnp;    char aacFileName[255];    char audioFileName[255];    char adtsFileName[255];    unsigned char header[8];    float length = 0;    FILE *hMP4File;/* System dependant types */#ifdef _WIN32    long begin;#else    clock_t begin;#endif    unsigned long cap = NeAACDecGetCapabilities();    fprintf(stderr, " *********** Ahead Software MPEG-4 AAC Decoder V%s ******************\n\n", FAAD2_VERSION);    fprintf(stderr, " Build: %s\n", __DATE__);    fprintf(stderr, " Copyright 2002-2004: Ahead Software AG\n");    fprintf(stderr, " http://www.audiocoding.com\n");    if (cap & FIXED_POINT_CAP)        fprintf(stderr, " Fixed point version\n");    else        fprintf(stderr, " Floating point version\n");    fprintf(stderr, "\n");    fprintf(stderr, " This program is free software; you can redistribute it and/or modify\n");    fprintf(stderr, " it under the terms of the GNU General Public License.\n");    fprintf(stderr, "\n");    fprintf(stderr, " **************************************************************************\n\n");    /* begin process command line */    progName = argv[0];    while (1) {        int c = -1;        int option_index = 0;        static struct option long_options[] = {            { "outfile",    0, 0, 'o' },            { "adtsout",    0, 0, 'a' },            { "oldformat",  0, 0, 't' },            { "format",     0, 0, 'f' },            { "bits",       0, 0, 'b' },            { "samplerate", 0, 0, 's' },            { "objecttype", 0, 0, 'l' },            { "downmix",    0, 0, 'd' },            { "info",       0, 0, 'i' },            { "stdio",      0, 0, 'w' },            { "stdio",      0, 0, 'g' },            { "help",       0, 0, 'h' }        };        c = getopt_long(argc, argv, "o:a:s:f:b:l:wgdhit",            long_options, &option_index);        if (c == -1)            break;        switch (c) {        case 'o':            if (optarg)            {                outfile_set = 1;                strcpy(audioFileName, optarg);            }            break;        case 'a':            if (optarg)            {                adts_out = 1;                strcpy(adtsFileName, optarg);            }            break;        case 's':            if (optarg)            {                char dr[10];                if (sscanf(optarg, "%s", dr) < 1) {                    def_srate = 0;                } else {                    def_srate = atoi(dr);                }            }            break;        case 'f':            if (optarg)            {                char dr[10];                if (sscanf(optarg, "%s", dr) < 1)                {                    format = 1;                } else {                    format = atoi(dr);                    if ((format < 1) || (format > 2))                        showHelp = 1;                }            }            break;        case 'b':            if (optarg)            {                char dr[10];                if (sscanf(optarg, "%s", dr) < 1)                {                    outputFormat = FAAD_FMT_16BIT; /* just use default */                } else {                    outputFormat = atoi(dr);                    if ((outputFormat < 1) || (outputFormat > 5))                        showHelp = 1;                }            }            break;        case 'l':            if (optarg)            {                char dr[10];                if (sscanf(optarg, "%s", dr) < 1)                {                    object_type = LC; /* default */                } else {                    object_type = atoi(dr);                    if ((object_type != LC) &&                        (object_type != MAIN) &&                        (object_type != LTP) &&                        (object_type != LD))                    {                        showHelp = 1;                    }                }            }            break;        case 't':            old_format = 1;            break;        case 'd':            downMatrix = 1;            break;        case 'w':            writeToStdio = 1;            break;        case 'g':            noGapless = 1;            break;        case 'i':            infoOnly = 1;            break;        case 'h':            showHelp = 1;            break;        default:            break;        }    }    /* check that we have at least two non-option arguments */    /* Print help if requested */    if (((argc - optind) < 1) || showHelp)    {        usage();        return 1;    }    /* only allow raw data on stdio */    if (writeToStdio == 1)    {        format = 2;    }    /* point to the specified file name */    strcpy(aacFileName, argv[optind]);#ifdef _WIN32    begin = GetTickCount();#else    begin = clock();#endif    /* Only calculate the path and open the file for writing if       we are not writing to stdout.     */    if(!writeToStdio && !outfile_set)    {        strcpy(audioFileName, aacFileName);        fnp = (char *)strrchr(audioFileName,'.');        if (fnp)            fnp[0] = '\0';        strcat(audioFileName, file_ext[format]);    }    /* check for mp4 file */    mp4file = 0;    hMP4File = fopen(aacFileName, "rb");    if (!hMP4File)    {        fprintf(stderr, "Error opening file: %s\n", aacFileName);        return 1;    }    fread(header, 1, 8, hMP4File);    fclose(hMP4File);    if (header[4] == 'f' && header[5] == 't' && header[6] == 'y' && header[7] == 'p')        mp4file = 1;    if (mp4file)    {        result = decodeMP4file(aacFileName, audioFileName, adtsFileName, writeToStdio,            outputFormat, format, downMatrix, noGapless, infoOnly, adts_out, &length);    } else {        result = decodeAACfile(aacFileName, audioFileName, adtsFileName, writeToStdio,            def_srate, object_type, outputFormat, format, downMatrix, infoOnly, adts_out,            old_format, &length);    }    if (!result && !infoOnly)    {#ifdef _WIN32        float dec_length = (float)(GetTickCount()-begin)/1000.0;        SetConsoleTitle("FAAD");#else        /* clock() grabs time since the start of the app but when we decode           multiple files, each file has its own starttime (begin).         */        float dec_length = (float)(clock() - begin)/(float)CLOCKS_PER_SEC;#endif        fprintf(stderr, "Decoding %s took: %5.2f sec. %5.2fx real-time.\n", aacFileName,            dec_length, length/dec_length);    }    return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -