On 7/31/2021 10:54 PM, Marton Balint wrote:
Signed-off-by: Marton Balint <c...@passwd.hu>
---
  libavcodec/mpeg12dec.c | 10 ++++++++--
  1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 858dca660c..129dc1c2aa 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -1529,7 +1529,7 @@ static void 
mpeg_decode_quant_matrix_extension(MpegEncContext *s)
          load_matrix(s, s->chroma_inter_matrix, NULL, 0);
  }
-static void mpeg_decode_picture_coding_extension(Mpeg1Context *s1)
+static int mpeg_decode_picture_coding_extension(Mpeg1Context *s1)
  {
      MpegEncContext *s = &s1->mpeg_enc_ctx;
@@ -1541,6 +1541,8 @@ static void mpeg_decode_picture_coding_extension(Mpeg1Context *s1)
      if (!s->pict_type && s1->mpeg_enc_ctx_allocated) {
          av_log(s->avctx, AV_LOG_ERROR,
                 "Missing picture start code, guessing missing values\n");

The guessing part will no longer be true when explode is set.

+        if (s->avctx->err_recognition & AV_EF_EXPLODE)
+            return AVERROR_INVALIDDATA;
          if (s->mpeg_f_code[1][0] == 15 && s->mpeg_f_code[1][1] == 15) {
              if (s->mpeg_f_code[0][0] == 15 && s->mpeg_f_code[0][1] == 15)
                  s->pict_type = AV_PICTURE_TYPE_I;
@@ -1586,6 +1588,8 @@ static void 
mpeg_decode_picture_coding_extension(Mpeg1Context *s1)
      ff_dlog(s->avctx, "alternate_scan=%d\n", s->alternate_scan);
      ff_dlog(s->avctx, "frame_pred_frame_dct=%d\n", s->frame_pred_frame_dct);
      ff_dlog(s->avctx, "progressive_frame=%d\n", s->progressive_frame);
+
+    return 0;
  }
static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size)
@@ -2599,7 +2603,9 @@ static int decode_chunks(AVCodecContext *avctx, AVFrame 
*picture,
                  break;
              case 0x8:
                  if (last_code == PICTURE_START_CODE) {
-                    mpeg_decode_picture_coding_extension(s);
+                    int ret = mpeg_decode_picture_coding_extension(s);
+                    if (ret < 0)
+                       return ret;
                  } else {
                      av_log(avctx, AV_LOG_ERROR,
                             "ignoring pic cod ext after %X\n", last_code);


_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to