| 51 | } |
| 52 | |
| 53 | static int mlp_parse(AVCodecParserContext *s, |
| 54 | AVCodecContext *avctx, |
| 55 | const uint8_t **poutbuf, int *poutbuf_size, |
| 56 | const uint8_t *buf, int buf_size) |
| 57 | { |
| 58 | MLPParseContext *mp = s->priv_data; |
| 59 | int sync_present; |
| 60 | uint8_t parity_bits; |
| 61 | int next; |
| 62 | int ret; |
| 63 | int i, p = 0; |
| 64 | |
| 65 | s->key_frame = 0; |
| 66 | |
| 67 | *poutbuf_size = 0; |
| 68 | *poutbuf = NULL; |
| 69 | if (buf_size == 0) |
| 70 | return 0; |
| 71 | |
| 72 | if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) { |
| 73 | next = buf_size; |
| 74 | } else { |
| 75 | if (!mp->in_sync) { |
| 76 | // Not in sync - find a major sync header |
| 77 | |
| 78 | for (i = 0; i < buf_size; i++) { |
| 79 | mp->pc.state = (mp->pc.state << 8) | buf[i]; |
| 80 | if ((mp->pc.state & 0xfffffffe) == 0xf8726fba && |
| 81 | // ignore if we do not have the data for the start of header |
| 82 | mp->pc.index + i >= 7) { |
| 83 | mp->in_sync = 1; |
| 84 | mp->bytes_left = 0; |
| 85 | break; |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | if (!mp->in_sync) { |
| 90 | if (ff_combine_frame(&mp->pc, END_NOT_FOUND, &buf, &buf_size) != -1) |
| 91 | av_log(avctx, AV_LOG_WARNING, "ff_combine_frame failed\n"); |
| 92 | return buf_size; |
| 93 | } |
| 94 | |
| 95 | if ((ret = ff_combine_frame(&mp->pc, i - 7, &buf, &buf_size)) < 0) { |
| 96 | av_log(avctx, AV_LOG_WARNING, "ff_combine_frame failed\n"); |
| 97 | return ret; |
| 98 | } |
| 99 | |
| 100 | return i - 7; |
| 101 | } |
| 102 | |
| 103 | if (mp->bytes_left == 0) { |
| 104 | // Find length of this packet |
| 105 | |
| 106 | /* Copy overread bytes from last frame into buffer. */ |
| 107 | for(; mp->pc.overread>0; mp->pc.overread--) { |
| 108 | mp->pc.buffer[mp->pc.index++]= mp->pc.buffer[mp->pc.overread_index++]; |
| 109 | } |
| 110 |
nothing calls this directly
no test coverage detected