FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavformat/mj2kdec.c
Date: 2023-06-04 16:45:34
Exec Total Coverage
Lines: 14 17 82.4%
Functions: 1 1 100.0%
Branches: 8 14 57.1%

Line Branch Exec Source
1 /*
2 * MJPEG 2000 Demuxer
3 * Copyright (c) 2016 Ståle Kristoffersen
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 #include "libavutil/intreadwrite.h"
23 #include "avformat.h"
24 #include "rawdec.h"
25
26 6860 static int mjpeg2000_probe(const AVProbeData *p)
27 {
28 6860 const uint8_t *b = p->buf;
29 int i, marker, marker_size;
30 6860 int frames = 0, invalid = 0;
31
32
2/2
✓ Branch 0 taken 142181141 times.
✓ Branch 1 taken 6860 times.
142188001 for (i = 0; i < p->buf_size - 5; i++) {
33
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 142181120 times.
142181141 if (AV_RB32(b) == 0xff4fff51){
34 21 marker_size = AV_RB16(b+4);
35
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 if (marker_size + i < p->buf_size - 4) {
36 21 marker = AV_RB8(b+4+marker_size);
37
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 6 times.
21 if (marker == 0xff)
38 15 frames++;
39 else
40 6 invalid++;
41 }
42 }
43 142181141 b += 1;
44 }
45
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6860 times.
6860 if (invalid*4 + 1 < frames) {
46 if (invalid == 0 && frames > 2)
47 return AVPROBE_SCORE_EXTENSION / 2;
48 return AVPROBE_SCORE_EXTENSION / 4;
49 }
50 6860 return 0;
51 }
52 FF_DEF_RAWVIDEO_DEMUXER2(mjpeg_2000, "raw MJPEG 2000 video", mjpeg2000_probe, "j2k", AV_CODEC_ID_JPEG2000, AVFMT_GENERIC_INDEX|AVFMT_NOTIMESTAMPS)
53