| 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 | |||
| 23 | 1457 | static int parse(AVCodecParserContext *s, | |
| 24 | AVCodecContext *avctx, | ||
| 25 | const uint8_t **poutbuf, int *poutbuf_size, | ||
| 26 | const uint8_t *buf, int buf_size) | ||
| 27 | { | ||
| 28 | unsigned int frame_type; | ||
| 29 | unsigned int profile; | ||
| 30 | |||
| 31 | 1457 | *poutbuf = buf; | |
| 32 | 1457 | *poutbuf_size = buf_size; | |
| 33 | |||
| 34 |
2/2✓ Branch 0 taken 29 times.
✓ Branch 1 taken 1428 times.
|
1457 | if (buf_size < 3) |
| 35 | 29 | return buf_size; | |
| 36 | |||
| 37 | 1428 | frame_type = buf[0] & 1; | |
| 38 | 1428 | profile = (buf[0] >> 1) & 7; | |
| 39 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1428 times.
|
1428 | if (profile > 3) { |
| 40 | ✗ | av_log(avctx, AV_LOG_ERROR, "Invalid profile %u.\n", profile); | |
| 41 | ✗ | return buf_size; | |
| 42 | } | ||
| 43 | |||
| 44 | 1428 | avctx->profile = profile; | |
| 45 | 1428 | s->key_frame = frame_type == 0; | |
| 46 |
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; |
| 47 | 1428 | s->format = AV_PIX_FMT_YUV420P; | |
| 48 | 1428 | s->field_order = AV_FIELD_PROGRESSIVE; | |
| 49 | 1428 | s->picture_structure = AV_PICTURE_STRUCTURE_FRAME; | |
| 50 | |||
| 51 |
2/2✓ Branch 0 taken 51 times.
✓ Branch 1 taken 1377 times.
|
1428 | if (frame_type == 0) { |
| 52 | unsigned int sync_code; | ||
| 53 | unsigned int width, height; | ||
| 54 | |||
| 55 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
|
51 | if (buf_size < 10) |
| 56 | ✗ | return buf_size; | |
| 57 | |||
| 58 | 51 | sync_code = AV_RL24(buf + 3); | |
| 59 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
|
51 | if (sync_code != 0x2a019d) { |
| 60 | ✗ | av_log(avctx, AV_LOG_ERROR, "Invalid sync code %06x.\n", sync_code); | |
| 61 | ✗ | return buf_size; | |
| 62 | } | ||
| 63 | |||
| 64 | 51 | width = AV_RL16(buf + 6) & 0x3fff; | |
| 65 | 51 | height = AV_RL16(buf + 8) & 0x3fff; | |
| 66 | |||
| 67 | 51 | s->width = width; | |
| 68 | 51 | s->height = height; | |
| 69 | 51 | s->coded_width = FFALIGN(width, 16); | |
| 70 | 51 | s->coded_height = FFALIGN(height, 16); | |
| 71 | } | ||
| 72 | |||
| 73 | 1428 | return buf_size; | |
| 74 | } | ||
| 75 | |||
| 76 | const AVCodecParser ff_vp8_parser = { | ||
| 77 | .codec_ids = { AV_CODEC_ID_VP8 }, | ||
| 78 | .parser_parse = parse, | ||
| 79 | }; | ||
| 80 |