1 /*
2 * Copyright (c) 2013 - Andre Roth <neolynx@gmail.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation version 2.1 of the License.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
17 *
18 */
19
20 #include <libdvbv5/mpeg_es.h>
21 #include <libdvbv5/descriptors.h>
22 #include <libdvbv5/dvb-fe.h>
23
24 #if __GNUC__ >= 9
25 #pragma GCC diagnostic ignored "-Waddress-of-packed-member"
26 #endif
27
dvb_mpeg_es_seq_start_init(const uint8_t * buf,ssize_t buflen,struct dvb_mpeg_es_seq_start * seq_start)28 int dvb_mpeg_es_seq_start_init(const uint8_t *buf, ssize_t buflen, struct dvb_mpeg_es_seq_start *seq_start)
29 {
30 if(buflen < sizeof(struct dvb_mpeg_es_seq_start))
31 return -1;
32 memcpy(seq_start, buf, sizeof(struct dvb_mpeg_es_seq_start));
33 bswap32(seq_start->bitfield);
34 bswap32(seq_start->bitfield2);
35 bswap32(seq_start->bitfield3);
36 return 0;
37 }
38
dvb_mpeg_es_seq_start_print(struct dvb_v5_fe_parms * parms,struct dvb_mpeg_es_seq_start * seq_start)39 void dvb_mpeg_es_seq_start_print(struct dvb_v5_fe_parms *parms, struct dvb_mpeg_es_seq_start *seq_start)
40 {
41 dvb_loginfo("MPEG ES SEQ START");
42 dvb_loginfo(" - width %d", seq_start->width);
43 dvb_loginfo(" - height %d", seq_start->height);
44 dvb_loginfo(" - aspect %d", seq_start->aspect);
45 dvb_loginfo(" - framerate %d", seq_start->framerate);
46 dvb_loginfo(" - bitrate %d", seq_start->bitrate);
47 dvb_loginfo(" - one %d", seq_start->one);
48 dvb_loginfo(" - vbv %d", seq_start->vbv);
49 dvb_loginfo(" - constrained %d", seq_start->constrained);
50 dvb_loginfo(" - qm_intra %d", seq_start->qm_intra);
51 dvb_loginfo(" - qm_nonintra %d", seq_start->qm_nonintra);
52 }
53
54 const char *dvb_mpeg_es_frame_names[5] = {
55 "?",
56 "I",
57 "P",
58 "B",
59 "D"
60 };
61
dvb_mpeg_es_pic_start_init(const uint8_t * buf,ssize_t buflen,struct dvb_mpeg_es_pic_start * pic_start)62 int dvb_mpeg_es_pic_start_init(const uint8_t *buf, ssize_t buflen, struct dvb_mpeg_es_pic_start *pic_start)
63 {
64 if(buflen < sizeof(struct dvb_mpeg_es_pic_start))
65 return -1;
66 memcpy(pic_start, buf, sizeof(struct dvb_mpeg_es_pic_start));
67 bswap32(pic_start->bitfield);
68 bswap32(pic_start->bitfield2);
69 return 0;
70 }
71
dvb_mpeg_es_pic_start_print(struct dvb_v5_fe_parms * parms,struct dvb_mpeg_es_pic_start * pic_start)72 void dvb_mpeg_es_pic_start_print(struct dvb_v5_fe_parms *parms, struct dvb_mpeg_es_pic_start *pic_start)
73 {
74 dvb_loginfo("MPEG ES PIC START");
75 dvb_loginfo(" - temporal_ref %d", pic_start->temporal_ref);
76 dvb_loginfo(" - coding_type %d (%s-frame)", pic_start->coding_type, dvb_mpeg_es_frame_names[pic_start->coding_type]);
77 dvb_loginfo(" - vbv_delay %d", pic_start->vbv_delay);
78 }
79