FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavformat/ipudec.c
Date: 2022-11-26 13:19:19
Exec Total Coverage
Lines: 3 28 10.7%
Branches: 1 12 8.3%

Line Branch Exec Source
1 /*
2 * IPU video demuxer
3 * Copyright (c) 2020 Paul B Mahol
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 "avformat.h"
23 #include "internal.h"
24 #include "avio_internal.h"
25 #include "rawdec.h"
26
27 #include "libavutil/intreadwrite.h"
28
29 6780 static int ipu_read_probe(const AVProbeData *p)
30 {
31
1/2
✓ Branch 0 taken 6780 times.
✗ Branch 1 not taken.
6780 if (AV_RB32(p->buf) != MKBETAG('i', 'p', 'u', 'm'))
32 6780 return 0;
33
34 if (AV_RL32(p->buf + 4) == 0)
35 return 0;
36
37 if (AV_RL16(p->buf + 8) == 0)
38 return 0;
39
40 if (AV_RL16(p->buf + 10) == 0)
41 return 0;
42
43 if (AV_RL32(p->buf + 12) == 0)
44 return 0;
45
46 return AVPROBE_SCORE_MAX;
47 }
48
49 static int ipu_read_header(AVFormatContext *s)
50 {
51 AVIOContext *pb = s->pb;
52 AVStream *st = avformat_new_stream(s, NULL);
53
54 if (!st)
55 return AVERROR(ENOMEM);
56 avio_skip(pb, 8);
57 st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
58 st->codecpar->codec_id = AV_CODEC_ID_IPU;
59 st->codecpar->width = avio_rl16(pb);
60 st->codecpar->height = avio_rl16(pb);
61 st->start_time = 0;
62 st->duration =
63 st->nb_frames = avio_rl32(pb);
64 ffstream(st)->need_parsing = AVSTREAM_PARSE_FULL_RAW;
65 avpriv_set_pts_info(st, 64, 1, 25);
66
67 return 0;
68 }
69
70 const AVInputFormat ff_ipu_demuxer = {
71 .name = "ipu",
72 .long_name = NULL_IF_CONFIG_SMALL("raw IPU Video"),
73 .read_probe = ipu_read_probe,
74 .read_header = ipu_read_header,
75 .read_packet = ff_raw_read_partial_packet,
76 .extensions = "ipu",
77 .flags = AVFMT_GENERIC_INDEX,
78 .raw_codec_id = AV_CODEC_ID_IPU,
79 .priv_data_size = sizeof(FFRawDemuxerContext),
80 .priv_class = &ff_raw_demuxer_class,
81 };
82