summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/avcodec.h4
-rw-r--r--libavcodec/encode.c8
2 files changed, 12 insertions, 0 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 65c8535359..9c246c455c 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2645,6 +2645,10 @@ int avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame);
* packets are ignored, and sending frames will return
* AVERROR_EOF.
*
+ * frame->time_base should be set to the same value as
+ * avctx->time_base. This is not required yet, but may be in
+ * the future.
+ *
* For audio:
* If AV_CODEC_CAP_VARIABLE_FRAME_SIZE is set, then each frame
* can have any number of samples.
diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index bd66f138a3..a774dc28dc 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -361,6 +361,14 @@ static int encode_send_frame_internal(AVCodecContext *avctx, const AVFrame *src)
AVFrame *dst = avci->buffer_frame;
int ret;
+ /* make sure the frame's timebase (if set) matches the encoder one */
+ if (src->time_base.num &&
+ (src->time_base.num != avctx->time_base.num ||
+ src->time_base.den != avctx->time_base.den)) {
+ av_log(avctx, AV_LOG_ERROR, "Mismatching frame/encoder time base\n");
+ return AVERROR(EINVAL);
+ }
+
if (avctx->codec->type == AVMEDIA_TYPE_AUDIO) {
/* extract audio service type metadata */
AVFrameSideData *sd = av_frame_get_side_data(src, AV_FRAME_DATA_AUDIO_SERVICE_TYPE);