Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copyright pes header flag - desc 06a reserved flags fix - desc 38 and 3f support - AU_Information #25

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
4 changes: 2 additions & 2 deletions atsc/si/desc_81.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ static inline uint8_t desc81_bit_rate_code_from_octetrate(uint64_t octetrate)
640,
};
for (unsigned i = 0; i < 19; i++) {
if (octetrate * 8 == table[i])
if (octetrate * 8 == table[i] * 1000)
return i;
else if (octetrate * 8 < table[i])
else if (octetrate * 8 < table[i] * 1000)
return 0x20 | i;
}
return 0xff;
Expand Down
4 changes: 2 additions & 2 deletions dvb/si/desc_6a.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ static inline void desc6a_init(uint8_t *p_desc)
{
desc_set_tag(p_desc, 0x6a);
desc_set_length(p_desc, (DESC6A_HEADER_SIZE - DESC_HEADER_SIZE));
p_desc[2] = 0x0f;
p_desc[2] = 0x00;
nriviera marked this conversation as resolved.
Show resolved Hide resolved
}

static inline void desc6a_clear_flags(uint8_t *p_desc)
{
p_desc[2] = 0x0f;
p_desc[2] = 0x00;
}

#define DEFINE_AC3_FLAG(FLAGNAME, bit) \
Expand Down
4 changes: 2 additions & 2 deletions dvb/si/sdt.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*****************************************************************************
* sdt.h: ETSI EN 300 468 Service Definition Table (SDT)
*****************************************************************************
* Copyright (C) 2009-2010 VideoLAN
* Copyright (C) 2009-2020 VideoLAN
*
* Authors: Christophe Massiot <[email protected]>
*
Expand Down Expand Up @@ -238,7 +238,7 @@ static inline bool sdt_table_validate(uint8_t **pp_sections)
if (!psi_check_crc(p_section))
return false;

if (!j)
if (!i)
i_onid = sdt_get_onid(p_section);
else if (sdt_get_onid(p_section) != i_onid)
return false;
Expand Down
2 changes: 1 addition & 1 deletion examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PREFIX ?= /usr/local
WARN = -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare
CPPFLAGS = -I. -I.. -I../..
CFLAGS := $(WARN) -O2 -g $(CFLAGS)
OBJ = dvb_print_si dvb_gen_si dvb_ecmg dvb_ecmg_test mpeg_print_pcr rtp_check_seqnum mpeg_restamp
OBJ = dvb_print_si dvb_gen_si dvb_ecmg dvb_ecmg_test mpeg_print_pcr mpeg_print_au_info rtp_check_seqnum mpeg_restamp

ifeq "$(shell uname -s)" "Linux"
LDFLAGS += -lrt
Expand Down
134 changes: 134 additions & 0 deletions examples/mpeg_print_au_info.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/*****************************************************************************
* mpeg_print_au_info.c: Prints adaptation field AU_INFO
*****************************************************************************
* Copyright (C) 2019 VideoLAN
*
* Authors: Roberto Corno <[email protected]>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*****************************************************************************/

#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <inttypes.h>
#include <string.h>
#include <stdio.h>

#include <bitstream/mpeg/ts.h>
#include <bitstream/mpeg/psi.h>
#include <bitstream/mpeg/au_info.h>

#include <fcntl.h>
/*****************************************************************************
* Local declarations
*****************************************************************************/
#define MAX_PIDS 8192
#define READ_ONCE 7

typedef struct ts_pid_t {
int i_psi_refcount;
int8_t i_last_cc;

/* biTStream PSI section gathering */
uint8_t *p_psi_buffer;
uint16_t i_psi_buffer_used;
} ts_pid_t;

typedef struct sid_t {
uint16_t i_sid, i_pmt_pid;
uint8_t *p_current_pmt;
} sid_t;

ts_pid_t p_pids[MAX_PIDS];


/*****************************************************************************
* Main loop
*****************************************************************************/
static void usage(const char *psz)
{
fprintf(stderr, "usage: %s < <input file> [> <output>]\n", psz);
exit(EXIT_FAILURE);
}

int main(int i_argc, char **ppsz_argv)
{
int i;

if (ppsz_argv[1] != NULL &&
(!strcmp(ppsz_argv[1], "-h") || !strcmp(ppsz_argv[1], "--help")))
usage(ppsz_argv[0]);

setvbuf(stdout, NULL, _IOLBF, 0);

memset(p_pids, 0, sizeof(p_pids));

for (i = 0; i < 8192; i++) {
p_pids[i].i_last_cc = -1;
psi_assemble_init( &p_pids[i].p_psi_buffer,
&p_pids[i].i_psi_buffer_used );
}

p_pids[PAT_PID].i_psi_refcount++;

uint64_t pnum = 0;
while (!feof(stdin) && !ferror(stdin)) {
uint8_t p_ts[TS_SIZE];
size_t i_ret = fread(p_ts, sizeof(p_ts), 1, stdin);
if (i_ret != 1) continue;
if (ts_validate(p_ts)) {
if (ts_has_adaptation(p_ts)) {
if (tsaf_has_transport_private_data(p_ts)) {
uint8_t tag = tsaf_get_private_data_tag(p_ts);
uint8_t len = tsaf_get_private_data_length(p_ts);
fprintf(stderr, "packet %lu ts private data [len %d] found [%d]\n", pnum, len, tag);
if (tag == 0x02) {
uint8_t *p_au = ts_private_data(p_ts);
p_au++;
uint8_t df_len = au_info_get_data_field_length(p_au);
fprintf(stderr, " AU_information len %d\n", df_len);
uint8_t code_fmt = au_info_get_au_coding_format(p_au);
uint8_t ctype_info = au_info_get_au_coding_type_info(p_au);
uint8_t ref_pic_icd = au_info_get_au_ref_pic_idc(p_au);
uint8_t pic_struct = au_info_get_au_pic_struct(p_au);
bool pts = au_info_get_pts_present(p_au);
bool prof_info = au_info_get_profile_info_present(p_au);
bool stream_info = au_info_get_stream_info_present(p_au);
fprintf(stderr, " AU_coding_format:%d AU_coding_type_info:%d\n",code_fmt, ctype_info);
fprintf(stderr, " AU_ref_pic_idc:%d AU_pic_struct:%d\n",ref_pic_icd, pic_struct);
fprintf(stderr, " PTS present:%d ProfileInfo present:%d Stream Info present:%d\n",pts, prof_info, stream_info);
if (pts) {
uint32_t pts32 = au_info_get_pts(p_au);
fprintf(stderr, " PTS :%u\n",pts32);
}
}
exit(0);
}
}
uint16_t i_pid = ts_get_pid(p_ts);
ts_pid_t *p_pid = &p_pids[i_pid];
p_pid->i_last_cc = ts_get_cc(p_ts);
pnum++;
}
}

return EXIT_FAILURE;
}
1 change: 1 addition & 0 deletions ieee/ethernet.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ extern "C"

#define ETHERNET_ADDR_LEN 6
#define ETHERNET_HEADER_LEN (2*ETHERNET_ADDR_LEN + 2)
#define ETHERNET_VLAN_LEN 4

#define ETHERNET_TYPE_IP 0x0800
#define ETHERNET_TYPE_ARP 0x0806
Expand Down
Loading