[FFmpeg-devel] [PATCH] 02: dtsdec: save flags, sample_rate, bit_rate in DTSContext

Pavlov Konstantin thresh
Tue May 15 16:20:10 CEST 2007


Hello.

Frame flags must be saved between calls to dts_decode_frame() (if the
input buffer did not hold a complete frame, flags for that frame will
be used by the next dts_decode_frame() call when the rest of frame
data is available).  Fixes "dts_frame() failed" errors in mplayer due
to uninitialized garbage in flags.

The sample_rate and bit_rate values also can be used by the next
dts_decode_frame() call; uninitialized values can lead to SIGFPE in
ffmpeg at the end of stream (when sample_rate == 0 is encountered).

Patch by Sergey Vlasov <vsu at altlinux.org>.

-- 
Fat Liberation: because a waist is a terrible thing to mind.
-------------- next part --------------
>From da97e88d62702a81508fd3c862164087936ccbb3 Mon Sep 17 00:00:00 2001
From: Sergey Vlasov <vsu at altlinux.ru>
Date: Tue, 15 May 2007 14:21:33 +0400
Subject: dtsdec: save flags, sample_rate, bit_rate in DTSContext

Frame flags must be saved between calls to dts_decode_frame() (if the
input buffer did not hold a complete frame, flags for that frame will
be used by the next dts_decode_frame() call when the rest of frame
data is available).  Fixes "dts_frame() failed" errors in mplayer due
to uninitialized garbage in flags.

The sample_rate and bit_rate values also can be used by the next
dts_decode_frame() call; uninitialized values can lead to SIGFPE in
ffmpeg at the end of stream (when sample_rate == 0 is encountered).

Signed-off-by: Sergey Vlasov <vsu at altlinux.ru>
---
 libavcodec/dtsdec.c |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/libavcodec/dtsdec.c b/libavcodec/dtsdec.c
index cf77a57..2a3c66a 100644
--- a/libavcodec/dtsdec.c
+++ b/libavcodec/dtsdec.c
@@ -36,6 +36,9 @@ typedef struct DTSContext {
     uint8_t buf[BUFFER_SIZE];
     uint8_t *bufptr;
     uint8_t *bufpos;
+    int flags;
+    int sample_rate;
+    int bit_rate;
 } DTSContext;
 
 static inline int16_t
@@ -173,10 +176,8 @@ dts_decode_frame(AVCodecContext * avctx, void *data, int *data_size,
     uint8_t *start = buff;
     uint8_t *end = buff + buff_size;
     int16_t *out_samples = data;
-    int sample_rate;
     int frame_length;
     int flags;
-    int bit_rate;
     int len;
     level_t level;
     sample_t bias;
@@ -201,8 +202,8 @@ dts_decode_frame(AVCodecContext * avctx, void *data, int *data_size,
         if(s->bufpos != s->buf + HEADER_SIZE)
             break;
 
-        length = dts_syncinfo(s->state, s->buf, &flags, &sample_rate,
-                              &bit_rate, &frame_length);
+        length = dts_syncinfo(s->state, s->buf, &s->flags, &s->sample_rate,
+                              &s->bit_rate, &frame_length);
         if(!length) {
             av_log(NULL, AV_LOG_INFO, "skip\n");
             for(s->bufptr = s->buf; s->bufptr < s->buf + HEADER_SIZE - 1; s->bufptr++)
@@ -215,15 +216,15 @@ dts_decode_frame(AVCodecContext * avctx, void *data, int *data_size,
     level = CONVERT_LEVEL;
     bias = CONVERT_BIAS;
 
-    flags |= DTS_ADJUST_LEVEL;
+    flags = s->flags | DTS_ADJUST_LEVEL;
     if(dts_frame(s->state, s->buf, &flags, &level, bias)) {
         av_log(avctx, AV_LOG_ERROR, "dts_frame() failed\n");
         goto end;
     }
 
-    avctx->sample_rate = sample_rate;
+    avctx->sample_rate = s->sample_rate;
     avctx->channels = channels_multi(flags);
-    avctx->bit_rate = bit_rate;
+    avctx->bit_rate = s->bit_rate;
 
     nblocks = dts_blocks_num(s->state);
 
-- 
1.5.1.1.197.g66b3

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



More information about the ffmpeg-devel mailing list