[FFmpeg-devel] [PATCH 02/13] lavc: add a sample_rate field to AVFrame.

Nicolas George nicolas.george at normalesup.org
Sat Apr 28 16:31:44 CEST 2012


The field is filled with the codec context information.

Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
---
 libavcodec/avcodec.h |    7 +++++++
 libavcodec/utils.c   |    2 ++
 2 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index a19e4ac..7b81203 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1265,6 +1265,13 @@ typedef struct AVFrame {
      */
     int64_t channel_layout;
 
+    /**
+     * sample rate of the audio frame
+     * - encoding: unused
+     * - decoding: read by user.
+     */
+    int sample_rate;
+
 } AVFrame;
 
 struct AVCodecInternal;
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 85c6351..4b6ddea 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1547,6 +1547,8 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx,
                 frame->format = avctx->sample_fmt;
             if (!frame->channel_layout)
                 frame->channel_layout = avctx->channel_layout;
+            if (!frame->sample_rate)
+                frame->sample_rate = avctx->sample_rate;
         }
 
         avctx->pkt = NULL;
-- 
1.7.2.5



More information about the ffmpeg-devel mailing list