Revision 97790352

View differences:

libavformat/spdifenc.c
60 60
    uint8_t *out_buf;               ///< pointer to the outgoing data before byte-swapping
61 61
    int out_bytes;                  ///< amount of outgoing bytes
62 62

  
63
    int extra_bswap;                ///< extra bswap for payload (for LE DTS => standard BE DTS)
64

  
63 65
    uint8_t *hd_buf;                ///< allocated buffer to concatenate hd audio frames
64 66
    int hd_buf_size;                ///< size of the hd audio buffer
65 67
    int hd_buf_count;               ///< number of frames in the hd audio buffer
......
124 126
        break;
125 127
    case DCA_MARKER_RAW_LE:
126 128
        blocks = (AV_RL16(pkt->data + 4) >> 2) & 0x7f;
129
        ctx->extra_bswap = 1;
127 130
        break;
128 131
    case DCA_MARKER_14B_BE:
129 132
        blocks =
......
132 135
    case DCA_MARKER_14B_LE:
133 136
        blocks =
134 137
            (((pkt->data[4] & 0x07) << 4) | ((pkt->data[7] & 0x3f) >> 2));
138
        ctx->extra_bswap = 1;
135 139
        break;
136 140
    default:
137 141
        av_log(s, AV_LOG_ERROR, "bad DTS syncword 0x%x\n", syncword_dts);
......
326 330
    ctx->out_buf = pkt->data;
327 331
    ctx->out_bytes = pkt->size;
328 332
    ctx->length_code = FFALIGN(pkt->size, 2) << 3;
333
    ctx->extra_bswap = 0;
329 334

  
330 335
    ret = ctx->header_info(s, pkt);
331 336
    if (ret < 0)
......
344 349
    put_le16(s->pb, ctx->data_type); //Pc
345 350
    put_le16(s->pb, ctx->length_code);//Pd
346 351

  
347
#if HAVE_BIGENDIAN
352
    if (HAVE_BIGENDIAN ^ ctx->extra_bswap) {
348 353
    put_buffer(s->pb, ctx->out_buf, ctx->out_bytes & ~1);
349
#else
354
    } else {
350 355
    av_fast_malloc(&ctx->buffer, &ctx->buffer_size, ctx->out_bytes + FF_INPUT_BUFFER_PADDING_SIZE);
351 356
    if (!ctx->buffer)
352 357
        return AVERROR(ENOMEM);
353 358
    ff_spdif_bswap_buf16((uint16_t *)ctx->buffer, (uint16_t *)ctx->out_buf, ctx->out_bytes >> 1);
354 359
    put_buffer(s->pb, ctx->buffer, ctx->out_bytes & ~1);
355
#endif
360
    }
356 361

  
357 362
    if (ctx->out_bytes & 1)
358 363
        put_be16(s->pb, ctx->out_buf[ctx->out_bytes - 1]);

Also available in: Unified diff