| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * This file is part of FFmpeg. | ||
| 3 | * | ||
| 4 | * FFmpeg is free software; you can redistribute it and/or | ||
| 5 | * modify it under the terms of the GNU Lesser General Public | ||
| 6 | * License as published by the Free Software Foundation; either | ||
| 7 | * version 2.1 of the License, or (at your option) any later version. | ||
| 8 | * | ||
| 9 | * FFmpeg is distributed in the hope that it will be useful, | ||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 12 | * Lesser General Public License for more details. | ||
| 13 | * | ||
| 14 | * You should have received a copy of the GNU Lesser General Public | ||
| 15 | * License along with FFmpeg; if not, write to the Free Software | ||
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 17 | */ | ||
| 18 | |||
| 19 | #include "libavutil/intreadwrite.h" | ||
| 20 | |||
| 21 | #include "avcodec.h" | ||
| 22 | #include "parser_internal.h" | ||
| 23 | |||
| 24 | 1457 | static int parse(AVCodecParserContext *s, | |
| 25 | AVCodecContext *avctx, | ||
| 26 | const uint8_t **poutbuf, int *poutbuf_size, | ||
| 27 | const uint8_t *buf, int buf_size) | ||
| 28 | { | ||
| 29 | unsigned int frame_type; | ||
| 30 | unsigned int profile; | ||
| 31 | |||
| 32 | 1457 | *poutbuf = buf; | |
| 33 | 1457 | *poutbuf_size = buf_size; | |
| 34 | |||
| 35 |
2/2✓ Branch 0 taken 29 times.
✓ Branch 1 taken 1428 times.
|
1457 | if (buf_size < 3) |
| 36 | 29 | return buf_size; | |
| 37 | |||
| 38 | 1428 | frame_type = buf[0] & 1; | |
| 39 | 1428 | profile = (buf[0] >> 1) & 7; | |
| 40 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1428 times.
|
1428 | if (profile > 3) { |
| 41 | ✗ | av_log(avctx, AV_LOG_ERROR, "Invalid profile %u.\n", profile); | |
| 42 | ✗ | return buf_size; | |
| 43 | } | ||
| 44 | |||
| 45 | 1428 | avctx->profile = profile; | |
| 46 | 1428 | s->key_frame = frame_type == 0; | |
| 47 |
2/2✓ Branch 0 taken 1377 times.
✓ Branch 1 taken 51 times.
|
1428 | s->pict_type = frame_type ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I; |
| 48 | 1428 | s->format = AV_PIX_FMT_YUV420P; | |
| 49 | 1428 | s->field_order = AV_FIELD_PROGRESSIVE; | |
| 50 | 1428 | s->picture_structure = AV_PICTURE_STRUCTURE_FRAME; | |
| 51 | |||
| 52 |
2/2✓ Branch 0 taken 51 times.
✓ Branch 1 taken 1377 times.
|
1428 | if (frame_type == 0) { |
| 53 | unsigned int sync_code; | ||
| 54 | unsigned int width, height; | ||
| 55 | |||
| 56 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
|
51 | if (buf_size < 10) |
| 57 | ✗ | return buf_size; | |
| 58 | |||
| 59 | 51 | sync_code = AV_RL24(buf + 3); | |
| 60 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
|
51 | if (sync_code != 0x2a019d) { |
| 61 | ✗ | av_log(avctx, AV_LOG_ERROR, "Invalid sync code %06x.\n", sync_code); | |
| 62 | ✗ | return buf_size; | |
| 63 | } | ||
| 64 | |||
| 65 | 51 | width = AV_RL16(buf + 6) & 0x3fff; | |
| 66 | 51 | height = AV_RL16(buf + 8) & 0x3fff; | |
| 67 | |||
| 68 | 51 | s->width = width; | |
| 69 | 51 | s->height = height; | |
| 70 | 51 | s->coded_width = FFALIGN(width, 16); | |
| 71 | 51 | s->coded_height = FFALIGN(height, 16); | |
| 72 | } | ||
| 73 | |||
| 74 | 1428 | return buf_size; | |
| 75 | } | ||
| 76 | |||
| 77 | const FFCodecParser ff_vp8_parser = { | ||
| 78 | PARSER_CODEC_LIST(AV_CODEC_ID_VP8), | ||
| 79 | .parse = parse, | ||
| 80 | }; | ||
| 81 |