From: Hendrik Leppkes <h.lepp...@gmail.com>

NOTE:

The dca parser needs to check that the framesize is actually of a complete
frame, and not of a partial DTS-HD frame, which is not constant size, and
thus the check would fail.

Review-by: Benjamin Larsson
Signed-off-by: Michael Niedermayer <michae...@gmx.at>
---
 libavcodec/dca_parser.c |   12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/libavcodec/dca_parser.c b/libavcodec/dca_parser.c
index e7b2ce4..7d284f1 100644
--- a/libavcodec/dca_parser.c
+++ b/libavcodec/dca_parser.c
@@ -40,7 +40,7 @@ typedef struct DCAParseContext {
 #define IS_MARKER(state, i, buf, buf_size) \
  ((state == DCA_MARKER_14B_LE && (i < buf_size-2) && (buf[i+1] & 0xF0) == 0xF0 
&& buf[i+2] == 0x07) \
  || (state == DCA_MARKER_14B_BE && (i < buf_size-2) && buf[i+1] == 0x07 && 
(buf[i+2] & 0xF0) == 0xF0) \
- || state == DCA_MARKER_RAW_LE || state == DCA_MARKER_RAW_BE)
+ || state == DCA_MARKER_RAW_LE || state == DCA_MARKER_RAW_BE || state == 
DCA_HD_MARKER)
 
 /**
  * Find the end of the current frame in the bitstream.
@@ -61,10 +61,7 @@ static int dca_find_frame_end(DCAParseContext * pc1, const 
uint8_t * buf,
         for (i = 0; i < buf_size; i++) {
             state = (state << 8) | buf[i];
             if (IS_MARKER(state, i, buf, buf_size)) {
-                if (pc1->lastmarker && state == pc1->lastmarker) {
-                    start_found = 1;
-                    break;
-                } else if (!pc1->lastmarker) {
+                if (!pc1->lastmarker || state == pc1->lastmarker || 
pc1->lastmarker == DCA_HD_MARKER) {
                     start_found = 1;
                     pc1->lastmarker = state;
                     break;
@@ -78,10 +75,11 @@ static int dca_find_frame_end(DCAParseContext * pc1, const 
uint8_t * buf,
             state = (state << 8) | buf[i];
             if (state == DCA_HD_MARKER && !pc1->hd_pos)
                 pc1->hd_pos = pc1->size;
-            if (state == pc1->lastmarker && IS_MARKER(state, i, buf, 
buf_size)) {
+            if (IS_MARKER(state, i, buf, buf_size) && (state == 
pc1->lastmarker || pc1->lastmarker == DCA_HD_MARKER)) {
                 if(pc1->framesize > pc1->size)
                     continue;
-                if(!pc1->framesize){
+                // We have to check that we really read a full frame here, and 
that it isn't a pure HD frame, because their size is not constant.
+                if(!pc1->framesize && state == pc1->lastmarker && state != 
DCA_HD_MARKER){
                     pc1->framesize = pc1->hd_pos ? pc1->hd_pos : pc1->size;
                 }
                 pc->frame_start_found = 0;
-- 
1.7.10

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

Reply via email to