rmenc: Drop the temporary buffer for ac3 byteswap

Use direcly avio_w8().

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
This commit is contained in:
Luca Barbato 2015-03-21 15:38:37 +01:00
parent 656e31ed87
commit d34039b171

View File

@ -355,31 +355,23 @@ static int rm_write_header(AVFormatContext *s)
static int rm_write_audio(AVFormatContext *s, const uint8_t *buf, int size, int flags) static int rm_write_audio(AVFormatContext *s, const uint8_t *buf, int size, int flags)
{ {
uint8_t *buf1;
RMMuxContext *rm = s->priv_data; RMMuxContext *rm = s->priv_data;
AVIOContext *pb = s->pb; AVIOContext *pb = s->pb;
StreamInfo *stream = rm->audio_stream; StreamInfo *stream = rm->audio_stream;
int i; int i;
/* XXX: suppress this malloc */
buf1 = av_malloc(size * sizeof(uint8_t));
if (!buf1)
return AVERROR(ENOMEM);
write_packet_header(s, stream, size, !!(flags & AV_PKT_FLAG_KEY)); write_packet_header(s, stream, size, !!(flags & AV_PKT_FLAG_KEY));
if (stream->enc->codec_id == AV_CODEC_ID_AC3) { if (stream->enc->codec_id == AV_CODEC_ID_AC3) {
/* for AC-3, the words seem to be reversed */ /* for AC-3, the words seem to be reversed */
for(i=0;i<size;i+=2) { for (i = 0; i < size; i += 2) {
buf1[i] = buf[i+1]; avio_w8(pb, buf[i + 1]);
buf1[i+1] = buf[i]; avio_w8(pb, buf[i]);
} }
avio_write(pb, buf1, size);
} else { } else {
avio_write(pb, buf, size); avio_write(pb, buf, size);
} }
stream->nb_frames++; stream->nb_frames++;
av_free(buf1);
return 0; return 0;
} }