]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/cbs.c
mpeg12: Move finding the best frame rate to common code
[ffmpeg] / libavcodec / cbs.c
index b5d5dfd2fd0530b8bafd82763d55d6ac4ad1bbd8..7440914939f6a698e5dcbbf5bf4b11aa26f87436 100644 (file)
@@ -34,6 +34,9 @@ static const CodedBitstreamType *cbs_type_table[] = {
 #if CONFIG_CBS_H265
     &ff_cbs_type_h265,
 #endif
+#if CONFIG_CBS_MPEG2
+    &ff_cbs_type_mpeg2,
+#endif
 };
 
 int ff_cbs_init(CodedBitstreamContext *ctx,
@@ -310,6 +313,12 @@ int ff_cbs_read_unsigned(CodedBitstreamContext *ctx, BitstreamContext *bc,
 
     av_assert0(width <= 32);
 
+    if (bitstream_bits_left(bc) < width) {
+        av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid value at "
+               "%s: bitstream ended.\n", name);
+        return AVERROR_INVALIDDATA;
+    }
+
     if (ctx->trace_enable)
         position = bitstream_tell(bc);