diff mbox series

[FFmpeg-devel,1/2] avcodec/dnxhd_parser: make parser more reliable for smaller VBR frame sizes

Message ID 20211031224826.77737-1-onemda@gmail.com
State New
Headers show
Series [FFmpeg-devel,1/2] avcodec/dnxhd_parser: make parser more reliable for smaller VBR frame sizes
Related show

Commit Message

Paul B Mahol Oct. 31, 2021, 10:48 p.m. UTC
Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 libavcodec/dnxhd_parser.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/dnxhd_parser.c b/libavcodec/dnxhd_parser.c
index 4ba619c9bb..ff80294cca 100644
--- a/libavcodec/dnxhd_parser.c
+++ b/libavcodec/dnxhd_parser.c
@@ -62,7 +62,14 @@  static int dnxhd_find_frame_end(DNXHDParserContext *dctx,
             dctx->cur_byte++;
             state = (state << 8) | buf[i];
 
-            if (dctx->cur_byte == 24) {
+            if (dctx->cur_byte > 42 && (state & 0xFFFFFFFF) == 0x600DC0DE) {
+                int remaining = i + 1;
+                pc->frame_start_found = 0;
+                pc->state64 = -1;
+                dctx->cur_byte = 0;
+                dctx->remaining = 0;
+                return remaining;
+            } else if (dctx->cur_byte == 24) {
                 dctx->h = (state >> 32) & 0xFFFF;
             } else if (dctx->cur_byte == 26) {
                 dctx->w = (state >> 32) & 0xFFFF;
@@ -74,11 +81,8 @@  static int dnxhd_find_frame_end(DNXHDParserContext *dctx,
                     continue;
 
                 remaining = avpriv_dnxhd_get_frame_size(cid);
-                if (remaining <= 0) {
-                    remaining = avpriv_dnxhd_get_hr_frame_size(cid, dctx->w, dctx->h);
-                    if (remaining <= 0)
-                        continue;
-                }
+                if (remaining <= 0)
+                    continue;
                 remaining += i - 47;
                 dctx->remaining = remaining;
                 if (buf_size >= dctx->remaining) {