[FFmpeg-cvslog] lavc: add a sample_rate field to AVFrame.

Nicolas George git at videolan.org
Sat Apr 28 20:30:11 CEST 2012


ffmpeg | branch: master | Nicolas George <nicolas.george at normalesup.org> | Sat Apr 28 14:07:50 2012 +0200| [128dda7016719fc763c0c9f754abb3196b9e18f3] | committer: Nicolas George

lavc: add a sample_rate field to AVFrame.

The field is filled with the codec context information.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=128dda7016719fc763c0c9f754abb3196b9e18f3
---

 libavcodec/avcodec.h |    9 +++++++++
 libavcodec/options.c |    1 +
 libavcodec/utils.c   |    2 ++
 3 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index fed72bb..ba51ec1 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1267,6 +1267,15 @@ typedef struct AVFrame {
      */
     int64_t channel_layout;
 
+    /**
+     * sample rate of the audio frame
+     * - encoding: unused
+     * - decoding: read by user.
+     * Code outside libavcodec should access this field using:
+     * av_opt_ptr(avcodec_get_frame_class(), frame, "sample_rate")
+     */
+    int sample_rate;
+
 } AVFrame;
 
 struct AVCodecInternal;
diff --git a/libavcodec/options.c b/libavcodec/options.c
index 173729c..3731b1f 100644
--- a/libavcodec/options.c
+++ b/libavcodec/options.c
@@ -240,6 +240,7 @@ static const AVOption frame_options[]={
 {"height", "", FOFFSET(height), AV_OPT_TYPE_INT, {.dbl = 0 }, 0, INT_MAX, 0},
 {"format", "", FOFFSET(format), AV_OPT_TYPE_INT, {.dbl = -1 }, 0, INT_MAX, 0},
 {"channel_layout", "", FOFFSET(channel_layout), AV_OPT_TYPE_INT64, {.dbl = 0 }, 0, INT64_MAX, 0},
+{"sample_rate", "", FOFFSET(sample_rate), AV_OPT_TYPE_INT, {.dbl = 0 }, 0, INT_MAX, 0},
 {NULL},
 };
 
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;



More information about the ffmpeg-cvslog mailing list