[FFmpeg-devel] [PATCHv2] af_hdcd: Add analyze mode
Michael Niedermayer
michael at niedermayer.cc
Sat Aug 6 14:28:53 EEST 2016
On Fri, Aug 05, 2016 at 05:23:04PM -0500, Burt P wrote:
> A new mode, selected by filter option, to aid in analysis of HDCD
> encoded audio. In this mode the audio is replaced by a solid tone and
> the amplitude is adjusted to signal some specified aspect of the process.
> The output file can be loaded in an audio editor alongside the original,
> where the user can see where different features or states are present.
[...]
> @@ -1358,18 +1478,32 @@ static void hdcd_process_stereo(HDCDContext *ctx, int32_t *samples, int count)
> count -= envelope_run;
> lead = run - envelope_run;
>
> - hdcd_control_stereo(ctx, &peak_extend[0], &peak_extend[1]);
> + ctlret = hdcd_control_stereo(ctx, &peak_extend[0], &peak_extend[1]);
> }
> if (lead > 0) {
> av_assert0(samples + lead * stride <= samples_end);
> - gain[0] = hdcd_envelope(samples, lead, stride, gain[0], ctx->val_target_gain, peak_extend[0]);
> - gain[1] = hdcd_envelope(samples + 1, lead, stride, gain[1], ctx->val_target_gain, peak_extend[1]);
> + if (ctx->analyze_mode) {
> + gain[0] = hdcd_analyze(samples, lead, stride, gain[0], ctx->val_target_gain, peak_extend[0],
> + ctx->analyze_mode,
> + ctx->state[0].sustain,
> + !!(ctlret == HDCD_TG_MISMATCH) );
> + gain[1] = hdcd_analyze(samples + 1, lead, stride, gain[1], ctx->val_target_gain, peak_extend[1],
> + ctx->analyze_mode,
> + ctx->state[1].sustain,
> + !!(ctlret == HDCD_TG_MISMATCH) );
> + } else {
> + gain[0] = hdcd_envelope(samples, lead, stride, gain[0], ctx->val_target_gain, peak_extend[0]);
> + gain[1] = hdcd_envelope(samples + 1, lead, stride, gain[1], ctx->val_target_gain, peak_extend[1]);
> + }
> }
>
> ctx->state[0].running_gain = gain[0];
> ctx->state[1].running_gain = gain[1];
> }
>
> +/* tone generator: sample_number, frequency, sample_rate, amplitude */
> +#define TONEGEN16(sn, f, sr, a) (int16_t)(sin((6.28318530718 * sn * f) /sr) * a * 0x7fff)
missing () for argument protection
TONEGEN16(1+1,2+3,4+5,6+7) wont do what one expects otherwise
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
The educated differ from the uneducated as much as the living from the
dead. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160806/ef583d06/attachment.sig>
More information about the ffmpeg-devel
mailing list