24 #include <hdcd/hdcd_simple.h> 47 #define OFFSET(x) offsetof(HDCDContext, x) 48 #define A AV_OPT_FLAG_AUDIO_PARAM 49 #define HDCD_ANA_MAX 6 51 {
"analyze_mode",
"Replace audio with solid tone and signal some processing aspect in the amplitude.",
53 {
"off", HDCD_ANA_OFF_DESC, 0,
AV_OPT_TYPE_CONST, { .i64 = HDCD_ANA_OFF}, 0, 0,
A,
"analyze_mode" },
54 {
"lle", HDCD_ANA_LLE_DESC, 0,
AV_OPT_TYPE_CONST, { .i64 = HDCD_ANA_LLE}, 0, 0,
A,
"analyze_mode" },
55 {
"pe", HDCD_ANA_PE_DESC, 0,
AV_OPT_TYPE_CONST, { .i64 = HDCD_ANA_PE}, 0, 0,
A,
"analyze_mode" },
56 {
"cdt", HDCD_ANA_CDT_DESC, 0,
AV_OPT_TYPE_CONST, { .i64 = HDCD_ANA_CDT}, 0, 0,
A,
"analyze_mode" },
57 {
"tgm", HDCD_ANA_TGM_DESC, 0,
AV_OPT_TYPE_CONST, { .i64 = HDCD_ANA_TGM}, 0, 0,
A,
"analyze_mode" },
58 {
"pel", HDCD_ANA_PEL_DESC, 0,
AV_OPT_TYPE_CONST, { .i64 = HDCD_ANA_PEL}, 0, 0,
A,
"analyze_mode" },
59 {
"ltgm", HDCD_ANA_LTGM_DESC, 0,
AV_OPT_TYPE_CONST, { .i64 = HDCD_ANA_LTGM}, 0, 0,
A,
"analyze_mode" },
76 const int16_t *in_data;
93 in_data = (int16_t *)in->
data[0];
95 for (n = 0; n < in->
nb_samples * channel_count; n++)
96 out_data[n] = in_data[n];
126 if (!in_formats || !out_formats)
140 char detect_str[256] =
"";
143 hdcd_detect_str(s->
shdcd, detect_str,
sizeof(detect_str));
150 static void af_hdcd_log(
const void *priv,
const char *fmt, va_list args)
159 s->
shdcd = hdcd_new();
189 .description =
NULL_IF_CONFIG_SMALL(
"Apply High Definition Compatible Digital (HDCD) decoding."),
191 .priv_class = &hdcd_class,
195 .
inputs = avfilter_af_hdcd_inputs,
196 .
outputs = avfilter_af_hdcd_outputs,
static void af_hdcd_log(const void *priv, const char *fmt, va_list args)
callback for error logging
This structure describes decoded (raw) audio or video data.
static const AVFilterPad outputs[]
Main libavfilter public API header.
static av_cold int init(AVFilterContext *ctx)
av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (%s)\, len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic ? ac->func_descr_generic :ac->func_descr)
#define LIBAVFILTER_VERSION_INT
#define AV_CH_LAYOUT_STEREO
const char * name
Pad name.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
AVFilterLink ** inputs
array of pointers to input links
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
#define AV_LOG_VERBOSE
Detailed information.
A filter pad used for either input or output.
A link between two filters.
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void * priv
private data for use by the filter
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
AVFilterFormats * in_formats
Lists of formats supported by the input and output filters respectively.
static const AVOption hdcd_options[]
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
uint64_t channel_layout
Channel layout of the audio data.
static const AVFilterPad avfilter_af_hdcd_outputs[]
audio channel layout utility functions
int analyze_mode
analyze mode replaces the audio with a solid tone and adjusts the amplitude to signal some specific a...
static av_cold void uninit(AVFilterContext *ctx)
static const AVFilterPad avfilter_af_hdcd_inputs[]
#define AV_LOG_INFO
Standard information.
AVSampleFormat
Audio Sample Formats.
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method !=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2) { ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc) { av_free(ac);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
Describe the class of an AVClass context structure.
static const AVFilterPad inputs[]
void av_vlog(void *avcl, int level, const char *fmt, va_list vl)
Send the specified message to the log if the level is less than or equal to the current av_log_level...
const char * name
Filter name.
AVFilterLink ** outputs
array of pointers to output links
enum MovChannelLayoutTag * layouts
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static const AVClass hdcd_class
AVFilterContext * dst
dest filter
static int query_formats(AVFilterContext *ctx)
int nb_samples
number of audio samples (per channel) described by this frame
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
AVFilterFormats * out_formats