The field is filled with the codec context information.tags/n0.11
@@ -1267,6 +1267,15 @@ typedef struct AVFrame { | |||||
*/ | */ | ||||
int64_t channel_layout; | 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; | } AVFrame; | ||||
struct AVCodecInternal; | struct AVCodecInternal; | ||||
@@ -240,6 +240,7 @@ static const AVOption frame_options[]={ | |||||
{"height", "", FOFFSET(height), 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}, | {"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}, | {"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}, | {NULL}, | ||||
}; | }; | ||||
@@ -1547,6 +1547,8 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, | |||||
frame->format = avctx->sample_fmt; | frame->format = avctx->sample_fmt; | ||||
if (!frame->channel_layout) | if (!frame->channel_layout) | ||||
frame->channel_layout = avctx->channel_layout; | frame->channel_layout = avctx->channel_layout; | ||||
if (!frame->sample_rate) | |||||
frame->sample_rate = avctx->sample_rate; | |||||
} | } | ||||
avctx->pkt = NULL; | avctx->pkt = NULL; | ||||