[FFmpeg-devel] [PATCH] Avoid a few shifts on each frame while decoding mpeg audio. (original) (raw)

Clément Bœsch ubitux
Sun Jan 16 21:53:38 CET 2011


Hi,

The MPEG audio parser seems to do a few useless shifts each time a new frame is sent for feeding; this patch avoids this (one read instead of 4 shifts). I ran the fate tests locally and it seems it didn't break anything.

Also, I don't understand the header_count field (in use a few lines below) so it may be wise to check if it is not related to what I tried to achieve.

Regards,

-- Cl?ment B. -------------- next part --------------

From beb7d21224596d98dd3eebca5fef43c74da5c1ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= Date: Sun, 16 Jan 2011 21:43:16 +0100 Subject: [PATCH] Avoid a few shifts on each frame while decoding mpeg audio.


libavcodec/mpegaudio_parser.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/libavcodec/mpegaudio_parser.c b/libavcodec/mpegaudio_parser.c index 6d7ab8a..5ced648 100644 --- a/libavcodec/mpegaudio_parser.c +++ b/libavcodec/mpegaudio_parser.c @@ -103,7 +103,11 @@ static int mpegaudio_parse(AVCodecParserContext *s1, while(i<buf_size){ int ret, sr, channels, bit_rate, frame_size; - state= (state<<8) + buf[i++]; + if (i == 0 && buf_size >= 4) { + state = AV_RB32(buf); + i += 4; + } else + state = (state<<8) + buf[i++]; ret = ff_mpa_decode_header(avctx, state, &sr, &channels, &frame_size, &bit_rate); if (ret < 4) {

1.7.3.5

-------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 490 bytes Desc: not available URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20110116/aa6c6d65/attachment.pgp>



More information about the ffmpeg-devel mailing list