summaryrefslogtreecommitdiffstats
path: root/libavfilter/af_hdcd.c
diff options
context:
space:
mode:
authorBurt P <pburt0@gmail.com>2016-07-23 21:26:48 -0500
committerMichael Niedermayer <michael@niedermayer.cc>2016-07-27 22:21:43 +0200
commit91854b8ef644207925cdc5d0dda1b130335d89f1 (patch)
tree74015b31b5da55ea7a99f2266f98368b8aa0dfa5 /libavfilter/af_hdcd.c
parentbfe9155aee1c8d0226b839204f21e231dcd01edd (diff)
downloadffmpeg-streaming-91854b8ef644207925cdc5d0dda1b130335d89f1.zip
ffmpeg-streaming-91854b8ef644207925cdc5d0dda1b130335d89f1.tar.gz
af_hdcd: Improve HDCD detection
HDCD is now only considered detected if a valid packet is active in both channels simultaneously. Signed-off-by: Burt P <pburt0@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavfilter/af_hdcd.c')
-rw-r--r--libavfilter/af_hdcd.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/libavfilter/af_hdcd.c b/libavfilter/af_hdcd.c
index 6f0db71..f68a105 100644
--- a/libavfilter/af_hdcd.c
+++ b/libavfilter/af_hdcd.c
@@ -1097,6 +1097,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
const int16_t *in_data;
int32_t *out_data;
int n, c;
+ int detect;
out = ff_get_audio_buffer(outlink, in->nb_samples);
if (!out) {
@@ -1112,19 +1113,22 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
out_data[n] = in_data[n];
}
+ detect = 0;
s->det_errors = 0;
for (c = 0; c < inlink->channels; c++) {
hdcd_state_t *state = &s->state[c];
hdcd_process(state, out_data + c, in->nb_samples, out->channels);
-
+ if (state->sustain) detect++;
s->uses_peak_extend |= !!state->count_peak_extend;
s->uses_transient_filter |= !!state->count_transient_filter;
s->max_gain_adjustment = FFMIN(s->max_gain_adjustment, GAINTOFLOAT(state->max_gain));
- s->hdcd_detected |= state->code_counterB || state->code_counterA;
s->det_errors += state->code_counterA_almost
+ state->code_counterB_checkfails
+ state->code_counterC_unmatched;
}
+ /* HDCD is detected if a valid packet is active in all (both)
+ * channels at the same time. */
+ if (detect == inlink->channels) s->hdcd_detected = 1;
av_frame_free(&in);
return ff_filter_frame(outlink, out);
OpenPOWER on IntegriCloud