OSDN Git Service

lavc: add a channel_layout field to AVFrame.
authorNicolas George <nicolas.george@normalesup.org>
Sat, 28 Apr 2012 11:02:41 +0000 (13:02 +0200)
committerNicolas George <nicolas.george@normalesup.org>
Sat, 28 Apr 2012 18:14:48 +0000 (20:14 +0200)
The field is filled with the codec context information.

FIXME need a minor version bump.

libavcodec/avcodec.h
libavcodec/options.c
libavcodec/utils.c

index c3a5192..fed72bb 100644 (file)
@@ -1257,6 +1257,16 @@ typedef struct AVFrame {
      * - decoding: Read by user.
      */
     int64_t pkt_pos;
+
+    /**
+     * channel layout 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, "channel_layout")
+     */
+    int64_t channel_layout;
+
 } AVFrame;
 
 struct AVCodecInternal;
index ef598d5..173729c 100644 (file)
@@ -239,6 +239,7 @@ static const AVOption frame_options[]={
 {"width", "", FOFFSET(width), AV_OPT_TYPE_INT, {.dbl = 0 }, 0, INT_MAX, 0},
 {"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},
 {NULL},
 };
 
index bd97431..85c6351 100644 (file)
@@ -1545,6 +1545,8 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx,
             frame->pkt_dts = avpkt->dts;
             if (frame->format == AV_SAMPLE_FMT_NONE)
                 frame->format = avctx->sample_fmt;
+            if (!frame->channel_layout)
+                frame->channel_layout = avctx->channel_layout;
         }
 
         avctx->pkt = NULL;