Mercurial > libavcodec.hg
comparison dca_parser.c @ 8226:ee1b8c54a603 libavcodec
Add support for parsing and decoding DCA-HD streams.
| author | kostya |
|---|---|
| date | Sat, 29 Nov 2008 10:06:37 +0000 |
| parents | 05987f234569 |
| children | e9d9d946f213 |
comparison
equal
deleted
inserted
replaced
| 8225:d133e597db2d | 8226:ee1b8c54a603 |
|---|---|
| 32 typedef struct DCAParseContext { | 32 typedef struct DCAParseContext { |
| 33 ParseContext pc; | 33 ParseContext pc; |
| 34 uint32_t lastmarker; | 34 uint32_t lastmarker; |
| 35 int size; | 35 int size; |
| 36 int framesize; | 36 int framesize; |
| 37 int hd_pos; | |
| 37 } DCAParseContext; | 38 } DCAParseContext; |
| 38 | 39 |
| 39 #define IS_MARKER(state, i, buf, buf_size) \ | 40 #define IS_MARKER(state, i, buf, buf_size) \ |
| 40 ((state == DCA_MARKER_14B_LE && (i < buf_size-2) && (buf[i+1] & 0xF0) == 0xF0 && buf[i+2] == 0x07) \ | 41 ((state == DCA_MARKER_14B_LE && (i < buf_size-2) && (buf[i+1] & 0xF0) == 0xF0 && buf[i+2] == 0x07) \ |
| 41 || (state == DCA_MARKER_14B_BE && (i < buf_size-2) && buf[i+1] == 0x07 && (buf[i+2] & 0xF0) == 0xF0) \ | 42 || (state == DCA_MARKER_14B_BE && (i < buf_size-2) && buf[i+1] == 0x07 && (buf[i+2] & 0xF0) == 0xF0) \ |
| 73 } | 74 } |
| 74 if (start_found) { | 75 if (start_found) { |
| 75 for (; i < buf_size; i++) { | 76 for (; i < buf_size; i++) { |
| 76 pc1->size++; | 77 pc1->size++; |
| 77 state = (state << 8) | buf[i]; | 78 state = (state << 8) | buf[i]; |
| 78 if (state == pc1->lastmarker && IS_MARKER(state, i, buf, buf_size) && (!pc1->framesize || pc1->framesize == pc1->size)) { | 79 if (state == DCA_HD_MARKER && !pc1->hd_pos) |
| 80 pc1->hd_pos = pc1->size; | |
| 81 if (state == pc1->lastmarker && IS_MARKER(state, i, buf, buf_size)) { | |
| 82 if(pc1->framesize > pc1->size) | |
| 83 continue; | |
| 84 if(!pc1->framesize){ | |
| 85 pc1->framesize = pc1->hd_pos ? pc1->hd_pos : pc1->size; | |
| 86 } | |
| 79 pc->frame_start_found = 0; | 87 pc->frame_start_found = 0; |
| 80 pc->state = -1; | 88 pc->state = -1; |
| 81 pc1->framesize = pc1->size; | |
| 82 pc1->size = 0; | 89 pc1->size = 0; |
| 83 return i - 3; | 90 return i - 3; |
| 84 } | 91 } |
| 85 } | 92 } |
| 86 } | 93 } |
