brintos

brintos / linux-shallow public Read only

0
0
Text · 2.6 KiB · 9cc94e4 Raw
98 lines · c
1/* SPDX-License-Identifier: GPL-2.0 */2/*3 * Vidtv serves as a reference DVB driver and helps validate the existing APIs4 * in the media subsystem. It can also aid developers working on userspace5 * applications.6 *7 * This file contains the code for an AES3 (also known as AES/EBU) encoder.8 * It is based on EBU Tech 3250 and SMPTE 302M technical documents.9 *10 * This encoder currently supports 16bit AES3 subframes using 16bit signed11 * integers.12 *13 * Note: AU stands for Access Unit, and AAU stands for Audio Access Unit14 *15 * Copyright (C) 2020 Daniel W. S. Almeida16 */17 18#ifndef VIDTV_S302M_H19#define VIDTV_S302M_H20 21#include <linux/types.h>22 23#include "vidtv_encoder.h"24 25/* see SMPTE 302M 2007 clause 7.3 */26#define VIDTV_S302M_BUF_SZ 6502427 28/* see ETSI TS 102 154 v.1.2.1 clause 7.3.5 */29#define VIDTV_S302M_FORMAT_IDENTIFIER 0x4253534430 31/**32 * struct vidtv_s302m_ctx - s302m encoder context.33 * @enc: A pointer to the containing encoder structure.34 * @frame_index: The current frame in a block35 * @au_count: The total number of access units encoded up to now36 * @last_duration: Duration of the tone currently being played37 * @note_offset: Position at the music tone array38 * @last_tone: Tone currently being played39 */40struct vidtv_s302m_ctx {41	struct vidtv_encoder *enc;42	u32 frame_index;43	u32 au_count;44	int last_duration;45	unsigned int note_offset;46	enum musical_notes last_tone;47};48 49/*50 * struct vidtv_smpte_s302m_es - s302m MPEG Elementary Stream header.51 *52 * See SMPTE 302M 2007 table 1.53 */54struct vidtv_smpte_s302m_es {55	/*56	 *57	 * audio_packet_size:16;58	 * num_channels:2;59	 * channel_identification:8;60	 * bits_per_sample:2; // 0x0 for 16bits61	 * zero:4;62	 */63	__be32 bitfield;64} __packed;65 66struct vidtv_s302m_frame_16 {67	u8 data[5];68} __packed;69 70/**71 * struct vidtv_s302m_encoder_init_args - Args for the s302m encoder.72 *73 * @name: A name to identify this particular instance74 * @src_buf: The source buffer, encoder will default to a sine wave if this is NULL.75 * @src_buf_sz: The size of the source buffer.76 * @es_pid: The MPEG Elementary Stream PID to use.77 * @sync: Attempt to synchronize audio with this video encoder, if not NULL.78 * @last_sample_cb: A callback called when the encoder runs out of data.79 * @head: Add to this chain80 */81struct vidtv_s302m_encoder_init_args {82	char *name;83	void *src_buf;84	u32 src_buf_sz;85	u16 es_pid;86	struct vidtv_encoder *sync;87	void (*last_sample_cb)(u32 sample_no);88 89	struct vidtv_encoder *head;90};91 92struct vidtv_encoder93*vidtv_s302m_encoder_init(struct vidtv_s302m_encoder_init_args args);94 95void vidtv_s302m_encoder_destroy(struct vidtv_encoder *encoder);96 97#endif /* VIDTV_S302M_H */98