Changeset 4014


Ignore:
Timestamp:
Apr 4, 2012 4:45:28 AM (12 years ago)
Author:
bennylp
Message:

Re #1446: set format to PCM when WAVE_FMT_TAG_PCM is detected in AVI file, so that other pjmedia components can recognize that it is a raw PCM format

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia/avi_player.c

    r3715 r4014  
    5959    { 
    6060        unsigned i; 
    61         pj_int32_t *data32 = (pj_int32_t *)data; 
    62         pj_int16_t *data16 = (pj_int16_t *)data; 
     61 
    6362        count /= (bits == 32? 4 : 2); 
    64         for (i=0; i<count; ++i) { 
    65             if (bits == 32) 
    66                 data32[i] = pj_swap32(data32[i]); 
    67             else 
    68                 data16[i] = pj_swap16(data16[i]); 
     63 
     64        if (bits == 32) { 
     65            pj_int32_t *data32 = (pj_int32_t *)data; 
     66            for (i=0; i<count; ++i) 
     67                data32[i] = pj_swap32(data32[i]); 
     68        } else { 
     69            pj_int16_t *data16 = (pj_int16_t *)data; 
     70            for (i=0; i<count; ++i) 
     71                data16[i] = pj_swap16(data16[i]); 
    6972        } 
     73 
    7074    } 
    7175    static void data_to_host2(void *data, pj_uint8_t nsizes, 
     
    99103    unsigned         stream_id; 
    100104    unsigned         options; 
     105    pjmedia_format_id fmt_id; 
    101106    pj_uint16_t      bits_per_sample; 
    102107    pj_bool_t        eof; 
     
    327332 
    328333    for (i = 0, nstr = 0; i < avi_hdr.avih_hdr.num_streams; i++) { 
     334        pjmedia_format_id fmt_id; 
     335 
    329336        /* Skip non-audio, non-video, or disabled streams) */ 
    330337        if ((!COMPARE_TAG(avi_hdr.strl_hdr[i].data_type,  
     
    355362                continue; 
    356363            } 
     364            fmt_id = avi_hdr.strl_hdr[i].codec; 
    357365        } else { 
    358366            /* Check supported audio formats here */ 
     
    366374                continue; 
    367375            } 
     376            /* Normalize format ID */ 
     377            fmt_id = avi_hdr.strl_hdr[i].codec; 
     378            if (avi_hdr.strl_hdr[i].codec == PJMEDIA_WAVE_FMT_TAG_PCM) 
     379                fmt_id = PJMEDIA_FORMAT_PCM; 
    368380        } 
    369381 
     
    382394 
    383395        fport[nstr]->stream_id = i; 
     396        fport[nstr]->fmt_id = fmt_id; 
    384397 
    385398        /* Open file. */ 
     
    434447            fport[i]->bits_per_sample = strf_hdr->bits_per_sample; 
    435448            pjmedia_format_init_audio(&fport[i]->base.info.fmt, 
    436                                       strl_hdr->codec, 
     449                                      fport[i]->fmt_id, 
    437450                                      strf_hdr->sample_rate, 
    438451                                      strf_hdr->nchannels, 
Note: See TracChangeset for help on using the changeset viewer.