Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Vidtv serves as a reference DVB driver and helps validate the existing APIs
0004  * in the media subsystem. It can also aid developers working on userspace
0005  * applications.
0006  *
0007  * This file contains the code for an AES3 (also known as AES/EBU) encoder.
0008  * It is based on EBU Tech 3250 and SMPTE 302M technical documents.
0009  *
0010  * This encoder currently supports 16bit AES3 subframes using 16bit signed
0011  * integers.
0012  *
0013  * Note: AU stands for Access Unit, and AAU stands for Audio Access Unit
0014  *
0015  * Copyright (C) 2020 Daniel W. S. Almeida
0016  */
0017 
0018 #ifndef VIDTV_S302M_H
0019 #define VIDTV_S302M_H
0020 
0021 #include <linux/types.h>
0022 
0023 #include "vidtv_encoder.h"
0024 
0025 /* see SMPTE 302M 2007 clause 7.3 */
0026 #define VIDTV_S302M_BUF_SZ 65024
0027 
0028 /* see ETSI TS 102 154 v.1.2.1 clause 7.3.5 */
0029 #define VIDTV_S302M_FORMAT_IDENTIFIER 0x42535344
0030 
0031 /**
0032  * struct vidtv_s302m_ctx - s302m encoder context.
0033  * @enc: A pointer to the containing encoder structure.
0034  * @frame_index: The current frame in a block
0035  * @au_count: The total number of access units encoded up to now
0036  * @last_duration: Duration of the tone currently being played
0037  * @note_offset: Position at the music tone array
0038  * @last_tone: Tone currently being played
0039  */
0040 struct vidtv_s302m_ctx {
0041     struct vidtv_encoder *enc;
0042     u32 frame_index;
0043     u32 au_count;
0044     int last_duration;
0045     unsigned int note_offset;
0046     enum musical_notes last_tone;
0047 };
0048 
0049 /*
0050  * struct vidtv_smpte_s302m_es - s302m MPEG Elementary Stream header.
0051  *
0052  * See SMPTE 302M 2007 table 1.
0053  */
0054 struct vidtv_smpte_s302m_es {
0055     /*
0056      *
0057      * audio_packet_size:16;
0058      * num_channels:2;
0059      * channel_identification:8;
0060      * bits_per_sample:2; // 0x0 for 16bits
0061      * zero:4;
0062      */
0063     __be32 bitfield;
0064 } __packed;
0065 
0066 struct vidtv_s302m_frame_16 {
0067     u8 data[5];
0068 } __packed;
0069 
0070 /**
0071  * struct vidtv_s302m_encoder_init_args - Args for the s302m encoder.
0072  *
0073  * @name: A name to identify this particular instance
0074  * @src_buf: The source buffer, encoder will default to a sine wave if this is NULL.
0075  * @src_buf_sz: The size of the source buffer.
0076  * @es_pid: The MPEG Elementary Stream PID to use.
0077  * @sync: Attempt to synchronize audio with this video encoder, if not NULL.
0078  * @last_sample_cb: A callback called when the encoder runs out of data.
0079  * @head: Add to this chain
0080  */
0081 struct vidtv_s302m_encoder_init_args {
0082     char *name;
0083     void *src_buf;
0084     u32 src_buf_sz;
0085     u16 es_pid;
0086     struct vidtv_encoder *sync;
0087     void (*last_sample_cb)(u32 sample_no);
0088 
0089     struct vidtv_encoder *head;
0090 };
0091 
0092 struct vidtv_encoder
0093 *vidtv_s302m_encoder_init(struct vidtv_s302m_encoder_init_args args);
0094 
0095 void vidtv_s302m_encoder_destroy(struct vidtv_encoder *encoder);
0096 
0097 #endif /* VIDTV_S302M_H */