ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

int frame_output_format ( mpg123_handle *  fr)

Definition at line 167 of file format.c.

Referenced by decode_update().

{
    struct audioformat nf;
    int f0=0;
    int f2=MPG123_ENCODINGS; /* Omit the 32bit and float encodings. */
    mpg123_pars *p = &fr->p;
    /* initialize new format, encoding comes later */
    nf.channels = fr->stereo;

    /* All this forcing should be removed in favour of the capabilities table... */
    if(p->flags & MPG123_FORCE_8BIT)
    {
        f0 = 6;
        f2 = 10;
    }
    if(p->flags & MPG123_FORCE_FLOAT)
    {
        f0 = 4;
        f2 = 6;
    }

    /* force stereo is stronger */
    if(p->flags & MPG123_FORCE_MONO)   nf.channels = 1;
    if(p->flags & MPG123_FORCE_STEREO) nf.channels = 2;

#ifndef NO_NTOM
    if(p->force_rate)
    {
        nf.rate = p->force_rate;
        if(cap_fit(fr,&nf,f0,2)) goto end;            /* 16bit encodings */
        if(cap_fit(fr,&nf,f0<=2 ? 2 : f0,f2)) goto end; /*  8bit encodings */

        /* try again with different stereoness */
        if(nf.channels == 2 && !(p->flags & MPG123_FORCE_STEREO)) nf.channels = 1;
        else if(nf.channels == 1 && !(p->flags & MPG123_FORCE_MONO)) nf.channels = 2;

        if(cap_fit(fr,&nf,f0,2)) goto end;            /* 16bit encodings */
        if(cap_fit(fr,&nf,f0<=2 ? 2 : f0,f2)) goto end; /*  8bit encodings */

        if(NOQUIET)
        error3( "Unable to set up output format! Constraints: %s%s%liHz.",
                ( p->flags & MPG123_FORCE_STEREO ? "stereo, " :
                  (p->flags & MPG123_FORCE_MONO ? "mono, " : "") ),
                (p->flags & MPG123_FORCE_8BIT ? "8bit, " : ""),
                p->force_rate );
/*      if(NOQUIET && p->verbose <= 1) print_capabilities(fr); */

        fr->err = MPG123_BAD_OUTFORMAT;
        return -1;
    }
#endif

    if(freq_fit(fr, &nf, f0, 2)) goto end; /* try rates with 16bit */
    if(freq_fit(fr, &nf, f0<=2 ? 2 : f0, f2)) goto end; /* ... 8bit */

    /* try again with different stereoness */
    if(nf.channels == 2 && !(p->flags & MPG123_FORCE_STEREO)) nf.channels = 1;
    else if(nf.channels == 1 && !(p->flags & MPG123_FORCE_MONO)) nf.channels = 2;

    if(freq_fit(fr, &nf, f0, 2)) goto end; /* try rates with 16bit */
    if(freq_fit(fr, &nf,  f0<=2 ? 2 : f0, f2)) goto end; /* ... 8bit */

    /* Here is the _bad_ end. */
    if(NOQUIET)
    {
        error5( "Unable to set up output format! Constraints: %s%s%li, %li or %liHz.",
                ( p->flags & MPG123_FORCE_STEREO ? "stereo, " :
                  (p->flags & MPG123_FORCE_MONO ? "mono, "  : "") ),
                (p->flags & MPG123_FORCE_8BIT  ? "8bit, " : ""),
                frame_freq(fr),  frame_freq(fr)>>1, frame_freq(fr)>>2 );
    }
/*  if(NOQUIET && p->verbose <= 1) print_capabilities(fr); */

    fr->err = MPG123_BAD_OUTFORMAT;
    return -1;

end: /* Here is the _good_ end. */
    /* we had a successful match, now see if there's a change */
    if(nf.rate == fr->af.rate && nf.channels == fr->af.channels && nf.encoding == fr->af.encoding)
    {
        debug2("Old format with %i channels, and FORCE_MONO=%li", nf.channels, p->flags & MPG123_FORCE_MONO);
        return 0; /* the same format as before */
    }
    else /* a new format */
    {
        debug1("New format with %i channels!", nf.channels);
        fr->af.rate = nf.rate;
        fr->af.channels = nf.channels;
        fr->af.encoding = nf.encoding;
        /* Cache the size of one sample in bytes, for ease of use. */
        if(fr->af.encoding & MPG123_ENC_8)
        fr->af.encsize = 1;
        else if(fr->af.encoding & MPG123_ENC_16)
        fr->af.encsize = 2;
        else if(fr->af.encoding & MPG123_ENC_32 || fr->af.encoding == MPG123_ENC_FLOAT_32)
        fr->af.encsize = 4;
        else if(fr->af.encoding == MPG123_ENC_FLOAT_64)
        fr->af.encsize = 8;
        else
        {
            if(NOQUIET) error1("Some unknown encoding??? (%i)", fr->af.encoding);

            fr->err = MPG123_BAD_OUTFORMAT;
            return -1;
        }
        return 1;
    }
}

Generated on Sat May 26 2012 04:43:41 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.