Ticket #1104: swab-and-tidy.patch

File swab-and-tidy.patch, 2.3 KB (added by anonymous, 12 years ago)
  • libs/libmyth/audiooutputdigitalencoder.cpp

     
    260260        unsigned char *data,
    261261        size_t &len)
    262262{
     263    unsigned char *payload = data + 8;  // skip header, currently 52 or 54bits
    263264    size_t enc_len;
    264265    int flags, sample_rate, bit_rate;
    265266
     
    274275    uint nr_samples = 0, block_len;
    275276    if (dts)
    276277    {
    277         enc_len = dts_syncinfo(data+8, &flags, &sample_rate, &bit_rate);
     278        enc_len = dts_syncinfo(payload, &flags, &sample_rate, &bit_rate);
    278279        int rate, sfreq, nblks;
    279         dts_decode_header(data+8, &rate, &nblks, &sfreq);
     280        dts_decode_header(payload, &rate, &nblks, &sfreq);
    280281        nr_samples = nblks * 32;
    281282        block_len = nr_samples * 2 * 2;
    282283    }
     
    284285    {
    285286#ifdef ENABLE_AC3_DECODER
    286287        enc_len = ac3_sync(
    287             data + 8, &flags, &sample_rate, &bit_rate, (int*)&block_len);
     288            payload, &flags, &sample_rate, &bit_rate, (int*)&block_len);
    288289        block_len *= 2 * 2;
    289290#else
    290         enc_len = a52_syncinfo(data + 8, &flags, &sample_rate, &bit_rate);
     291        enc_len = a52_syncinfo(payload, &flags, &sample_rate, &bit_rate);
    291292        block_len = MAX_AC3_FRAME_SIZE;
    292293#endif
    293294    }
     
    301302
    302303    enc_len = min((uint)enc_len, block_len - 8);
    303304
    304     //uint32_t x = *(uint32_t*)(data+8);
     305    //uint32_t x = *(uint32_t*)payload;
    305306    // in place swab
    306     swab(data + 8, data + 8, enc_len);
     307    swab((const char *)payload, (char *)payload, enc_len);
    307308    //VERBOSE(VB_AUDIO|VB_TIMESTAMP,
    308309    //        QString("DigitalEncoder::Encode swab test %1 %2")
    309     //        .arg(x,0,16).arg(*(uint32_t*)(data+8),0,16));
     310    //        .arg(x,0,16).arg(*(uint32_t*)payload,0,16));
    310311
    311312    // the following values come from libmpcodecs/ad_hwac3.c in mplayer.
    312313    // they form a valid IEC958 AC3 header.
     
    350351    data[5] = 0x00;
    351352    data[6] = (enc_len << 3) & 0xFF;
    352353    data[7] = (enc_len >> 5) & 0xFF;
    353     memset(data + 8 + enc_len, 0, block_len - 8 - enc_len);
     354    memset(payload + enc_len, 0, block_len - 8 - enc_len);
    354355    len = block_len;
    355356
    356357    return enc_len;