[FFmpeg-cvslog] avcodec/dca_parser: simplify state machine

foo86 git at videolan.org
Tue May 31 16:46:52 CEST 2016


ffmpeg | branch: master | foo86 <foobaz86 at gmail.com> | Tue May 31 14:46:13 2016 +0300| [1f7b67a1caef19842533e2831350312d5b6c3f5f] | committer: James Almer

avcodec/dca_parser: simplify state machine

Signed-off-by: James Almer <jamrial at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1f7b67a1caef19842533e2831350312d5b6c3f5f
---

 libavcodec/dca_parser.c |   34 +++++++++++++++-------------------
 1 file changed, 15 insertions(+), 19 deletions(-)

diff --git a/libavcodec/dca_parser.c b/libavcodec/dca_parser.c
index d76b548..1521a5b 100644
--- a/libavcodec/dca_parser.c
+++ b/libavcodec/dca_parser.c
@@ -109,25 +109,25 @@ static int dca_find_frame_end(DCAParseContext *pc1, const uint8_t *buf,
                 case DCA_SYNCWORD_CORE_LE:
                     if (size == 2) {
                         pc1->framesize = CORE_FRAMESIZE(STATE_LE(state));
-                        start_found    = 2;
+                        start_found    = 4;
                     }
                     break;
                 case DCA_SYNCWORD_CORE_14B_BE:
                     if (size == 4) {
                         pc1->framesize = CORE_FRAMESIZE(STATE_14(state)) * 8 / 14 * 2;
-                        start_found    = 2;
+                        start_found    = 4;
                     }
                     break;
                 case DCA_SYNCWORD_CORE_14B_LE:
                     if (size == 4) {
                         pc1->framesize = CORE_FRAMESIZE(STATE_14(STATE_LE(state))) * 8 / 14 * 2;
-                        start_found    = 2;
+                        start_found    = 4;
                     }
                     break;
                 case DCA_SYNCWORD_SUBSTREAM:
                     if (size == 6) {
                         pc1->framesize = EXSS_FRAMESIZE(state);
-                        start_found    = 2;
+                        start_found    = 4;
                     }
                     break;
                 default:
@@ -136,23 +136,19 @@ static int dca_find_frame_end(DCAParseContext *pc1, const uint8_t *buf,
                 continue;
             }
 
-            if (pc1->lastmarker == DCA_SYNCWORD_CORE_BE) {
-                if (pc1->framesize > size + 2)
-                    continue;
-
-                if (start_found == 2 && IS_EXSS_MARKER(state)) {
-                    pc1->framesize = size + 2;
-                    start_found    = 3;
-                    continue;
-                }
+            if (start_found == 2 && IS_EXSS_MARKER(state) &&
+                pc1->framesize <= size + 2) {
+                pc1->framesize  = size + 2;
+                start_found     = 3;
+                continue;
+            }
 
-                if (start_found == 3) {
-                    if (size == pc1->framesize + 4) {
-                        pc1->framesize += EXSS_FRAMESIZE(state);
-                        start_found     = 4;
-                    }
-                    continue;
+            if (start_found == 3) {
+                if (size == pc1->framesize + 4) {
+                    pc1->framesize += EXSS_FRAMESIZE(state);
+                    start_found     = 4;
                 }
+                continue;
             }
 
             if (pc1->framesize > size)



More information about the ffmpeg-cvslog mailing list