ffmpeg-cvslog
Threads by month
- ----- 2026 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
August 2016
- 5 participants
- 460 discussions
ffmpeg | branch: master | Anton Khirnov <anton(a)khirnov.net> | Thu May 19 08:19:14 2016 +0200| [996f13413b0415097e2a184d161462ffb3ceb647] | committer: Anton Khirnov
h264: fix warnings in fill_filter_caches_inter()
The code does some weird casting to a 2-dimensional sub-array of
ref2frm. This is not necessary, since only one dimension is needed
there.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=996f13413b0415097…
---
libavcodec/h264_slice.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index eee222f..c6eae12 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -1750,12 +1750,12 @@ static av_always_inline void fill_filter_caches_inter(const H264Context *h,
if (USES_LIST(top_type, list)) {
const int b_xy = h->mb2b_xy[top_xy] + 3 * b_stride;
const int b8_xy = 4 * top_xy + 2;
- int (*ref2frm)[64] = h->ref2frm[h->slice_table[top_xy] & (MAX_SLICES - 1)][0] + (MB_MBAFF(sl) ? 20 : 2);
+ const int *ref2frm = &h->ref2frm[h->slice_table[top_xy] & (MAX_SLICES - 1)][list][(MB_MBAFF(sl) ? 20 : 2)];
AV_COPY128(mv_dst - 1 * 8, h->cur_pic.motion_val[list][b_xy + 0]);
ref_cache[0 - 1 * 8] =
- ref_cache[1 - 1 * 8] = ref2frm[list][h->cur_pic.ref_index[list][b8_xy + 0]];
+ ref_cache[1 - 1 * 8] = ref2frm[h->cur_pic.ref_index[list][b8_xy + 0]];
ref_cache[2 - 1 * 8] =
- ref_cache[3 - 1 * 8] = ref2frm[list][h->cur_pic.ref_index[list][b8_xy + 1]];
+ ref_cache[3 - 1 * 8] = ref2frm[h->cur_pic.ref_index[list][b8_xy + 1]];
} else {
AV_ZERO128(mv_dst - 1 * 8);
AV_WN32A(&ref_cache[0 - 1 * 8], ((LIST_NOT_USED) & 0xFF) * 0x01010101u);
@@ -1765,15 +1765,15 @@ static av_always_inline void fill_filter_caches_inter(const H264Context *h,
if (USES_LIST(left_type[LTOP], list)) {
const int b_xy = h->mb2b_xy[left_xy[LTOP]] + 3;
const int b8_xy = 4 * left_xy[LTOP] + 1;
- int (*ref2frm)[64] = h->ref2frm[h->slice_table[left_xy[LTOP]] & (MAX_SLICES - 1)][0] + (MB_MBAFF(sl) ? 20 : 2);
+ const int *ref2frm = &h->ref2frm[h->slice_table[left_xy[LTOP]] & (MAX_SLICES - 1)][list][(MB_MBAFF(sl) ? 20 : 2)];
AV_COPY32(mv_dst - 1 + 0, h->cur_pic.motion_val[list][b_xy + b_stride * 0]);
AV_COPY32(mv_dst - 1 + 8, h->cur_pic.motion_val[list][b_xy + b_stride * 1]);
AV_COPY32(mv_dst - 1 + 16, h->cur_pic.motion_val[list][b_xy + b_stride * 2]);
AV_COPY32(mv_dst - 1 + 24, h->cur_pic.motion_val[list][b_xy + b_stride * 3]);
ref_cache[-1 + 0] =
- ref_cache[-1 + 8] = ref2frm[list][h->cur_pic.ref_index[list][b8_xy + 2 * 0]];
+ ref_cache[-1 + 8] = ref2frm[h->cur_pic.ref_index[list][b8_xy + 2 * 0]];
ref_cache[-1 + 16] =
- ref_cache[-1 + 24] = ref2frm[list][h->cur_pic.ref_index[list][b8_xy + 2 * 1]];
+ ref_cache[-1 + 24] = ref2frm[h->cur_pic.ref_index[list][b8_xy + 2 * 1]];
} else {
AV_ZERO32(mv_dst - 1 + 0);
AV_ZERO32(mv_dst - 1 + 8);
@@ -1798,9 +1798,9 @@ static av_always_inline void fill_filter_caches_inter(const H264Context *h,
{
int8_t *ref = &h->cur_pic.ref_index[list][4 * mb_xy];
- int (*ref2frm)[64] = h->ref2frm[sl->slice_num & (MAX_SLICES - 1)][0] + (MB_MBAFF(sl) ? 20 : 2);
- uint32_t ref01 = (pack16to32(ref2frm[list][ref[0]], ref2frm[list][ref[1]]) & 0x00FF00FF) * 0x0101;
- uint32_t ref23 = (pack16to32(ref2frm[list][ref[2]], ref2frm[list][ref[3]]) & 0x00FF00FF) * 0x0101;
+ const int *ref2frm = &h->ref2frm[sl->slice_num & (MAX_SLICES - 1)][list][(MB_MBAFF(sl) ? 20 : 2)];
+ uint32_t ref01 = (pack16to32(ref2frm[ref[0]], ref2frm[ref[1]]) & 0x00FF00FF) * 0x0101;
+ uint32_t ref23 = (pack16to32(ref2frm[ref[2]], ref2frm[ref[3]]) & 0x00FF00FF) * 0x0101;
AV_WN32A(&ref_cache[0 * 8], ref01);
AV_WN32A(&ref_cache[1 * 8], ref01);
AV_WN32A(&ref_cache[2 * 8], ref23);
1
0
af_hdcd: Warn if there is any resampling or format conversion in the link chain
by git@videolan.org 01 Aug '16
by git@videolan.org 01 Aug '16
01 Aug '16
ffmpeg | branch: master | Burt P <pburt0(a)gmail.com> | Fri Jul 29 12:36:22 2016 -0500| [bea17a3d57053e77a9b3f46291f9d620dd76f7a2] | committer: Michael Niedermayer
af_hdcd: Warn if there is any resampling or format conversion in the link chain
HDCD is only encoded in s16@44100Hz. Scan the chain of AVFilterLinks
for any resampling or format conversion/truncation that might cause
problems for the filter and issue warnings.
Signed-off-by: Burt P <pburt0(a)gmail.com>
Signed-off-by: Michael Niedermayer <michael(a)niedermayer.cc>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bea17a3d57053e77a…
---
libavfilter/af_hdcd.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 58 insertions(+), 4 deletions(-)
diff --git a/libavfilter/af_hdcd.c b/libavfilter/af_hdcd.c
index 683c588..2ca2950 100644
--- a/libavfilter/af_hdcd.c
+++ b/libavfilter/af_hdcd.c
@@ -885,6 +885,11 @@ typedef struct HDCDContext {
* default is off */
int force_pe;
+ /* config_input() and config_output() scan links for any resampling
+ * or format changes. If found, warnings are issued and bad_config
+ * is set. */
+ int bad_config;
+
AVFilterContext *fctx; /* filter context for logging errors */
int sample_count; /* used in error logging */
int val_target_gain; /* last matching target_gain in both channels */
@@ -1519,25 +1524,29 @@ static av_cold void uninit(AVFilterContext *ctx)
/* log the HDCD decode information */
if (s->hdcd_detected)
av_log(ctx, AV_LOG_INFO,
- "HDCD detected: yes, peak_extend: %s, max_gain_adj: %0.1f dB, transient_filter: %s, detectable errors: %d%s\n",
+ "HDCD detected: yes, peak_extend: %s, max_gain_adj: %0.1f dB, transient_filter: %s, detectable errors: %d%s%s\n",
pe_str[s->peak_extend],
s->max_gain_adjustment,
(s->uses_transient_filter) ? "detected" : "not detected",
- s->det_errors, (s->det_errors) ? " (try -v verbose)" : ""
+ s->det_errors, (s->det_errors) ? " (try -v verbose)" : "",
+ (s->bad_config) ? " (bad_config)" : ""
);
else
- av_log(ctx, AV_LOG_INFO, "HDCD detected: no\n");
+ av_log(ctx, AV_LOG_INFO, "HDCD detected: no%s\n",
+ (s->bad_config) ? " (bad_config)" : ""
+ );
}
+
static av_cold int init(AVFilterContext *ctx)
{
-
HDCDContext *s = ctx->priv;
int c;
s->max_gain_adjustment = 0.0;
s->sample_count = 0;
s->fctx = ctx;
+ s->bad_config = 0;
for (c = 0; c < HDCD_MAX_CHANNELS; c++) {
hdcd_reset(&s->state[c], 44100);
@@ -1551,19 +1560,64 @@ static av_cold int init(AVFilterContext *ctx)
return 0;
}
+static int config_input(AVFilterLink *inlink) {
+ AVFilterContext *ctx = inlink->dst;
+ HDCDContext *s = ctx->priv;
+ AVFilterLink *lk = inlink;
+ while(lk != NULL) {
+ AVFilterContext *nextf = lk->src;
+ if (lk->format != AV_SAMPLE_FMT_S16 || lk->sample_rate != 44100) {
+ av_log(ctx, AV_LOG_WARNING, "An input format is %s@%dHz at %s. It will truncated/resampled to s16(a)44100Hz.\n",
+ av_get_sample_fmt_name(lk->format), lk->sample_rate,
+ (nextf->name) ? nextf->name : "<unknown>"
+ );
+ s->bad_config = 1;
+ break;
+ }
+ lk = (nextf->inputs) ? nextf->inputs[0] : NULL;
+ }
+ /* more warning will appear after config_output() */
+ return 0;
+}
+
static const AVFilterPad avfilter_af_hdcd_inputs[] = {
{
.name = "default",
.type = AVMEDIA_TYPE_AUDIO,
.filter_frame = filter_frame,
+ .config_props = config_input,
},
{ NULL }
};
+static int config_output(AVFilterLink *outlink) {
+ static const char hdcd_baduse[] =
+ "The HDCD filter is unlikely to produce a desirable result in this context.";
+ AVFilterContext *ctx = outlink->src;
+ HDCDContext *s = ctx->priv;
+ AVFilterLink *lk = outlink;
+ while(lk != NULL) {
+ AVFilterContext *nextf = lk->dst;
+ if (lk->format == AV_SAMPLE_FMT_S16 || lk->format == AV_SAMPLE_FMT_U8) {
+ av_log(ctx, AV_LOG_WARNING, "s24 output is being truncated to %s at %s. (Try -f s24le after the filter)\n",
+ av_get_sample_fmt_name(lk->format),
+ (nextf->name) ? nextf->name : "<unknown>"
+ );
+ s->bad_config = 1;
+ break;
+ }
+ lk = (nextf->outputs) ? nextf->outputs[0] : NULL;
+ }
+ if (s->bad_config)
+ av_log(ctx, AV_LOG_WARNING, "%s\n", hdcd_baduse);
+ return 0;
+}
+
static const AVFilterPad avfilter_af_hdcd_outputs[] = {
{
.name = "default",
.type = AVMEDIA_TYPE_AUDIO,
+ .config_props = config_output,
},
{ NULL }
};
1
0
ffmpeg | branch: master | Burt P <pburt0(a)gmail.com> | Mon Aug 1 14:28:39 2016 -0500| [d574e22659bd51cdf16723a204fef65a9e783f1d] | committer: Michael Niedermayer
af_hdcd: Process stereo channels together, fix #5727
Issue #5727: gain adjustment should only be applied if matching
gain value from a valid packet in both channels. The existing functions process
each channel separately, so it was not possible.
* New versions of hdcd_process(), hdcd_scan(), hdcd_integrate() named
hdcd_*_stereo() that process both channels together.
* target_gain applied will be the last matching target_gain.
* The old single channel functions remain as an option. They can be
used by: -af hdcd=process_stereo=0.
Signed-off-by: Burt P <pburt0(a)gmail.com>
Signed-off-by: Michael Niedermayer <michael(a)niedermayer.cc>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d574e22659bd51cdf…
---
libavfilter/af_hdcd.c | 287 +++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 249 insertions(+), 38 deletions(-)
diff --git a/libavfilter/af_hdcd.c b/libavfilter/af_hdcd.c
index 0752c39..683c588 100644
--- a/libavfilter/af_hdcd.c
+++ b/libavfilter/af_hdcd.c
@@ -863,10 +863,22 @@ static const char * const pe_str[] = {
"enabled permanently"
};
+#define HDCD_PROCESS_STEREO_DEFAULT 1
+#define HDCD_MAX_CHANNELS 2
+
+/* convert to float from 4-bit (3.1) fixed-point
+ * the always-negative value is stored positive, so make it negative */
+#define GAINTOFLOAT(g) (g) ? -(float)(g>>1) - ((g & 1) ? 0.5 : 0.0) : 0.0
+
typedef struct HDCDContext {
const AVClass *class;
- hdcd_state_t state[2];
+ hdcd_state_t state[HDCD_MAX_CHANNELS];
+ /* use hdcd_*_stereo() functions to process both channels together.
+ * -af hdcd=process_stereo=0 for off
+ * -af hdcd=process_stereo=1 for on
+ * default is HDCD_PROCESS_STEREO_DEFAULT */
+ int process_stereo;
/* always extend peaks above -3dBFS even if PE isn't signaled
* -af hdcd=force_pe=0 for off
* -af hdcd=force_pe=1 for on
@@ -875,6 +887,7 @@ typedef struct HDCDContext {
AVFilterContext *fctx; /* filter context for logging errors */
int sample_count; /* used in error logging */
+ int val_target_gain; /* last matching target_gain in both channels */
/* User information/stats */
int hdcd_detected;
@@ -886,9 +899,11 @@ typedef struct HDCDContext {
#define OFFSET(x) offsetof(HDCDContext, x)
static const AVOption hdcd_options[] = {
+ { "process_stereo", "Process stereo channels together. Only apply target_gain when both channels match.",
+ OFFSET(process_stereo), AV_OPT_TYPE_INT, { .i64 = HDCD_PROCESS_STEREO_DEFAULT }, 0, 1, 0 },
{ "force_pe", "Always extend peaks above -3dBFS even when PE is not signaled.",
OFFSET(force_pe), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, 0 },
- {NULL}
+ {NULL}
};
AVFILTER_DEFINE_CLASS(hdcd);
@@ -915,12 +930,10 @@ static void hdcd_reset(hdcd_state_t *state, unsigned rate)
state->code_counterB_checkfails = 0;
state->code_counterC = 0;
state->code_counterC_unmatched = 0;
-
state->count_peak_extend = 0;
state->count_transient_filter = 0;
for(i = 0; i < 16; i++) state->gain_counts[i] = 0;
state->max_gain = 0;
-
state->count_sustain_expired = -1;
}
@@ -1037,6 +1050,76 @@ static int hdcd_integrate(HDCDContext *ctx, hdcd_state_t *state, int *flag, cons
return result;
}
+static int hdcd_integrate_stereo(HDCDContext *ctx, int *flag, const int32_t *samples, int count)
+{
+ uint32_t bits[2] = {0, 0};
+ int result;
+ int i;
+ *flag = 0;
+
+ /* result = min(count, s0ra, s1ra) */
+ result = FFMIN(ctx->state[0].readahead, count);
+ result = FFMIN(ctx->state[1].readahead, result);
+
+ for (i = result - 1; i >= 0; i--) {
+ bits[0] |= (*(samples++) & 1) << i;
+ bits[1] |= (*(samples++) & 1) << i;
+ }
+
+ for (i = 0; i < 2; i++) {
+ ctx->state[i].window = (ctx->state[i].window << result) | bits[i];
+ ctx->state[i].readahead -= result;
+
+ if (ctx->state[i].readahead == 0) {
+ uint32_t wbits = (ctx->state[i].window ^ ctx->state[i].window >> 5 ^ ctx->state[i].window >> 23);
+ if (ctx->state[i].arg) {
+ switch (hdcd_code(wbits, &ctx->state[i].control)) {
+ case HDCD_CODE_A:
+ *flag |= i+1;
+ ctx->state[i].code_counterA++;
+ break;
+ case HDCD_CODE_B:
+ *flag |= i+1;
+ ctx->state[i].code_counterB++;
+ break;
+ case HDCD_CODE_A_ALMOST:
+ ctx->state[i].code_counterA_almost++;
+ av_log(ctx->fctx, AV_LOG_VERBOSE,
+ "hdcd error: Control A almost: 0x%02x near %d\n", wbits & 0xff, ctx->sample_count);
+ break;
+ case HDCD_CODE_B_CHECKFAIL:
+ ctx->state[i].code_counterB_checkfails++;
+ av_log(ctx->fctx, AV_LOG_VERBOSE,
+ "hdcd error: Control B check failed: 0x%04x (0x%02x vs 0x%02x) near %d\n", wbits & 0xffff, (wbits & 0xff00) >> 8, ~wbits & 0xff, ctx->sample_count);
+ break;
+ case HDCD_CODE_NONE:
+ ctx->state[i].code_counterC_unmatched++;
+ av_log(ctx->fctx, AV_LOG_VERBOSE,
+ "hdcd error: Unmatched code: 0x%08x near %d\n", wbits, ctx->sample_count);
+ default:
+ av_log(ctx->fctx, AV_LOG_INFO,
+ "hdcd error: Unexpected return value from hdcd_code()\n");
+ av_assert0(0); /* die */
+ }
+ if (*flag&(i+1)) hdcd_update_info(&ctx->state[i]);
+ ctx->state[i].arg = 0;
+ }
+ if (wbits == 0x7e0fa005 || wbits == 0x7e0fa006) {
+ /* 0x7e0fa00[.]-> [0b0101 or 0b0110] */
+ ctx->state[i].readahead = (wbits & 3) * 8;
+ ctx->state[i].arg = 1;
+ ctx->state[i].code_counterC++;
+ } else {
+ if (wbits)
+ ctx->state[i].readahead = readaheadtab[wbits & 0xff];
+ else
+ ctx->state[i].readahead = 31; /* ffwd over digisilence */
+ }
+ }
+ }
+ return result;
+}
+
static void hdcd_sustain_reset(hdcd_state_t *state)
{
state->sustain = state->sustain_reset;
@@ -1048,9 +1131,9 @@ static void hdcd_sustain_reset(hdcd_state_t *state)
static int hdcd_scan(HDCDContext *ctx, hdcd_state_t *state, const int32_t *samples, int max, int stride)
{
+ int result;
int cdt_active = 0;
/* code detect timer */
- int result;
if (state->sustain > 0) {
cdt_active = 1;
if (state->sustain <= max) {
@@ -1059,6 +1142,7 @@ static int hdcd_scan(HDCDContext *ctx, hdcd_state_t *state, const int32_t *sampl
}
state->sustain -= max;
}
+
result = 0;
while (result < max) {
int flag;
@@ -1074,6 +1158,48 @@ static int hdcd_scan(HDCDContext *ctx, hdcd_state_t *state, const int32_t *sampl
/* code detect timer expired */
if (cdt_active && state->sustain == 0)
state->count_sustain_expired++;
+
+ return result;
+}
+
+static int hdcd_scan_stereo(HDCDContext *ctx, const int32_t *samples, int max)
+{
+ int result;
+ int i;
+ int cdt_active[2] = {0, 0};
+
+ /* code detect timers for each channel */
+ for(i=0; i<2; i++) {
+ if (ctx->state[i].sustain > 0) {
+ cdt_active[i] = 1;
+ if (ctx->state[i].sustain <= max) {
+ ctx->state[i].control = 0;
+ max = ctx->state[i].sustain;
+ }
+ ctx->state[i].sustain -= max;
+ }
+ }
+
+ result = 0;
+ while (result < max) {
+ int flag;
+ int consumed = hdcd_integrate_stereo(ctx, &flag, samples, max - result);
+ result += consumed;
+ if (flag) {
+ /* reset timer if code detected in a channel */
+ if (flag & 1) hdcd_sustain_reset(&ctx->state[0]);
+ if (flag & 2) hdcd_sustain_reset(&ctx->state[1]);
+ break;
+ }
+ samples += consumed * 2;
+ }
+
+ for(i=0; i<2; i++) {
+ /* code detect timer expired */
+ if (cdt_active[i] && ctx->state[i].sustain == 0)
+ ctx->state[i].count_sustain_expired++;
+ }
+
return result;
}
@@ -1143,6 +1269,30 @@ static void hdcd_control(HDCDContext *ctx, hdcd_state_t *state, int *peak_extend
*target_gain = (state->control & 15) << 7;
}
+typedef enum {
+ HDCD_OK=0,
+ HDCD_TG_MISMATCH
+} hdcd_control_result_t;
+
+static hdcd_control_result_t hdcd_control_stereo(HDCDContext *ctx, int *peak_extend0, int *peak_extend1)
+{
+ int target_gain[2];
+ hdcd_control(ctx, &ctx->state[0], peak_extend0, &target_gain[0]);
+ hdcd_control(ctx, &ctx->state[1], peak_extend1, &target_gain[1]);
+ if (target_gain[0] == target_gain[1])
+ ctx->val_target_gain = target_gain[0];
+ else {
+ av_log(ctx->fctx, AV_LOG_VERBOSE,
+ "hdcd error: Unmatched target_gain near %d: tg0: %0.1f, tg1: %0.1f, lvg: %0.1f\n",
+ ctx->sample_count,
+ GAINTOFLOAT(target_gain[0] >>7),
+ GAINTOFLOAT(target_gain[1] >>7),
+ GAINTOFLOAT(ctx->val_target_gain >>7) );
+ return HDCD_TG_MISMATCH;
+ }
+ return HDCD_OK;
+}
+
static void hdcd_process(HDCDContext *ctx, hdcd_state_t *state, int32_t *samples, int count, int stride)
{
int32_t *samples_end = samples + count * stride;
@@ -1175,9 +1325,44 @@ static void hdcd_process(HDCDContext *ctx, hdcd_state_t *state, int32_t *samples
state->running_gain = gain;
}
-/* convert to float from 4-bit (3.1) fixed-point
- * the always-negative value is stored positive, so make it negative */
-#define GAINTOFLOAT(g) (g) ? -(float)(g>>1) - ((g & 1) ? 0.5 : 0.0) : 0.0
+static void hdcd_process_stereo(HDCDContext *ctx, int32_t *samples, int count)
+{
+ const int stride = 2;
+ int32_t *samples_end = samples + count * stride;
+ int gain[2] = {ctx->state[0].running_gain, ctx->state[1].running_gain};
+ int peak_extend[2];
+ int lead = 0;
+
+ hdcd_control_stereo(ctx, &peak_extend[0], &peak_extend[1]);
+ while (count > lead) {
+ int envelope_run, run;
+
+ av_assert0(samples + lead * stride + stride * (count - lead) <= samples_end);
+ run = hdcd_scan_stereo(ctx, samples + lead * stride, count - lead) + lead;
+ envelope_run = run - 1;
+
+ av_assert0(samples + envelope_run * stride <= samples_end);
+
+ if (envelope_run) {
+ gain[0] = hdcd_envelope(samples, envelope_run, stride, gain[0], ctx->val_target_gain, peak_extend[0]);
+ gain[1] = hdcd_envelope(samples + 1, envelope_run, stride, gain[1], ctx->val_target_gain, peak_extend[1]);
+ }
+
+ samples += envelope_run * stride;
+ count -= envelope_run;
+ lead = run - envelope_run;
+
+ 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]);
+ }
+
+ ctx->state[0].running_gain = gain[0];
+ ctx->state[1].running_gain = gain[1];
+}
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
{
@@ -1188,7 +1373,6 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
const int16_t *in_data;
int32_t *out_data;
int n, c;
- int detect, packets, pe_packets;
out = ff_get_audio_buffer(outlink, in->nb_samples);
if (!out) {
@@ -1204,35 +1388,60 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
out_data[n] = in_data[n];
}
- detect = 0;
- packets = 0;
- pe_packets = 0;
- s->det_errors = 0;
- for (c = 0; c < inlink->channels; c++) {
- hdcd_state_t *state = &s->state[c];
- hdcd_process(s, state, out_data + c, in->nb_samples, out->channels);
- if (state->sustain) detect++;
- packets += state->code_counterA + state->code_counterB;
- pe_packets += 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->det_errors += state->code_counterA_almost
- + state->code_counterB_checkfails
- + state->code_counterC_unmatched;
- }
- if (pe_packets) {
- /* if every valid packet has used PE, call it permanent */
- if (packets == pe_packets)
- s->peak_extend = HDCD_PE_PERMANENT;
- else
- s->peak_extend = HDCD_PE_INTERMITTENT;
+ s->det_errors = 0; /* re-sum every pass */
+ if (s->process_stereo && inlink->channels == 2) {
+ float mga = 0.0;
+ hdcd_process_stereo(s, out_data, in->nb_samples);
+ /* HDCD is detected if a valid packet is active in both
+ * channels at the same time. */
+ if (s->state[0].sustain && s->state[1].sustain) s->hdcd_detected = 1;
+ if (s->state[0].count_peak_extend || s->state[1].count_peak_extend) {
+ int packets = s->state[0].code_counterA
+ + s->state[0].code_counterB
+ + s->state[1].code_counterA
+ + s->state[1].code_counterB;
+ /* if every valid packet has used PE, call it permanent */
+ if (packets == s->state[0].count_peak_extend + s->state[1].count_peak_extend)
+ s->peak_extend = HDCD_PE_PERMANENT;
+ else
+ s->peak_extend = HDCD_PE_INTERMITTENT;
+ } else s->peak_extend = HDCD_PE_NEVER;
+ s->uses_transient_filter = (s->state[0].count_transient_filter || s->state[1].count_transient_filter);
+ mga = FFMIN(GAINTOFLOAT(s->state[0].max_gain), GAINTOFLOAT(s->state[1].max_gain));
+ s->max_gain_adjustment = FFMIN(s->max_gain_adjustment, mga);
+ s->det_errors += s->state[0].code_counterA_almost
+ + s->state[0].code_counterB_checkfails
+ + s->state[0].code_counterC_unmatched
+ + s->state[1].code_counterA_almost
+ + s->state[1].code_counterB_checkfails
+ + s->state[1].code_counterC_unmatched;
} else {
- s->peak_extend = HDCD_PE_NEVER;
+ int detect=0;
+ int packets=0;
+ int pe_packets=0;
+ for (c = 0; c < inlink->channels; c++) {
+ hdcd_state_t *state = &s->state[c];
+ hdcd_process(s, state, out_data + c, in->nb_samples, out->channels);
+ if (state->sustain) detect++;
+ packets += state->code_counterA + state->code_counterB;
+ pe_packets += 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->det_errors += state->code_counterA_almost
+ + state->code_counterB_checkfails
+ + state->code_counterC_unmatched;
+ }
+ if (pe_packets) {
+ /* if every valid packet has used PE, call it permanent */
+ if (packets == pe_packets)
+ s->peak_extend = HDCD_PE_PERMANENT;
+ else
+ s->peak_extend = HDCD_PE_INTERMITTENT;
+ } else s->peak_extend = HDCD_PE_NEVER;
+ /* HDCD is detected if a valid packet is active in all
+ * channels at the same time. */
+ if (detect == inlink->channels) s->hdcd_detected = 1;
}
- /* 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;
-
s->sample_count += in->nb_samples * in->channels;
av_frame_free(&in);
@@ -1291,7 +1500,7 @@ static av_cold void uninit(AVFilterContext *ctx)
int i, j;
/* dump the state for each channel for AV_LOG_VERBOSE */
- for (i = 0; i < 2; i++) {
+ for (i = 0; i < HDCD_MAX_CHANNELS; i++) {
hdcd_state_t *state = &s->state[i];
av_log(ctx, AV_LOG_VERBOSE, "Channel %d: counter A: %d, B: %d, C: %d\n", i,
state->code_counterA, state->code_counterB, state->code_counterC);
@@ -1330,10 +1539,12 @@ static av_cold int init(AVFilterContext *ctx)
s->sample_count = 0;
s->fctx = ctx;
- for (c = 0; c < 2; c++) {
+ for (c = 0; c < HDCD_MAX_CHANNELS; c++) {
hdcd_reset(&s->state[c], 44100);
}
+ av_log(ctx, AV_LOG_VERBOSE, "Process mode: %s\n",
+ (s->process_stereo) ? "process stereo channels together" : "process each channel separately");
av_log(ctx, AV_LOG_VERBOSE, "Force PE: %s\n",
(s->force_pe) ? "on" : "off");
1
0
ffmpeg | branch: master | James Almer <jamrial(a)gmail.com> | Mon Aug 1 18:15:07 2016 -0300| [517dd04f6df3103a6f2bc20b43b956d055ad983f] | committer: James Almer
Merge commit 'bc7f4268514624e1286ea76d27a89a56b4ee18e1'
* commit 'bc7f4268514624e1286ea76d27a89a56b4ee18e1':
h264: drop tests whether the codec id is AV_CODEC_ID_H264
Conflicts:
libavcodec/h264dec.c
Merged-by: James Almer <jamrial(a)gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=517dd04f6df3103a6…
---
libavcodec/h264_slice.c | 1 -
libavcodec/h264dec.c | 14 ++++++--------
2 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index fcc8443..7d1817c 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -2349,7 +2349,6 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg)
sl->deblocking_filter = 0;
sl->is_complex = FRAME_MBAFF(h) || h->picture_structure != PICT_FRAME ||
- avctx->codec_id != AV_CODEC_ID_H264 ||
(CONFIG_GRAY && (h->flags & AV_CODEC_FLAG_GRAY));
if (!(h->avctx->active_thread_type & FF_THREAD_SLICE) && h->picture_structure == PICT_FRAME && h->slice_ctx[0].er.error_status_table) {
diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index d944a8c..323639d 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -406,15 +406,13 @@ av_cold int ff_h264_decode_init(AVCodecContext *avctx)
return AVERROR_UNKNOWN;
}
- if (avctx->codec_id == AV_CODEC_ID_H264) {
- if (avctx->ticks_per_frame == 1) {
- if(h->avctx->time_base.den < INT_MAX/2) {
- h->avctx->time_base.den *= 2;
- } else
- h->avctx->time_base.num /= 2;
- }
- avctx->ticks_per_frame = 2;
+ if (avctx->ticks_per_frame == 1) {
+ if(h->avctx->time_base.den < INT_MAX/2) {
+ h->avctx->time_base.den *= 2;
+ } else
+ h->avctx->time_base.num /= 2;
}
+ avctx->ticks_per_frame = 2;
if (avctx->extradata_size > 0 && avctx->extradata) {
ret = ff_h264_decode_extradata(avctx->extradata, avctx->extradata_size,
======================================================================
diff --cc libavcodec/h264_slice.c
index fcc8443,eee222f..7d1817c
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@@ -2349,19 -2111,8 +2349,18 @@@ static int decode_slice(struct AVCodecC
sl->deblocking_filter = 0;
sl->is_complex = FRAME_MBAFF(h) || h->picture_structure != PICT_FRAME ||
- avctx->codec_id != AV_CODEC_ID_H264 ||
(CONFIG_GRAY && (h->flags & AV_CODEC_FLAG_GRAY));
+ if (!(h->avctx->active_thread_type & FF_THREAD_SLICE) && h->picture_structure == PICT_FRAME && h->slice_ctx[0].er.error_status_table) {
+ const int start_i = av_clip(sl->resync_mb_x + sl->resync_mb_y * h->mb_width, 0, h->mb_num - 1);
+ if (start_i) {
+ int prev_status = h->slice_ctx[0].er.error_status_table[h->slice_ctx[0].er.mb_index2xy[start_i - 1]];
+ prev_status &= ~ VP_START;
+ if (prev_status != (ER_MV_END | ER_DC_END | ER_AC_END))
+ h->slice_ctx[0].er.error_occurred = 1;
+ }
+ }
+
if (h->ps.pps->cabac) {
/* realign */
align_get_bits(&sl->gb);
diff --cc libavcodec/h264dec.c
index d944a8c,cc5bdca..323639d
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@@ -406,24 -371,18 +406,22 @@@ av_cold int ff_h264_decode_init(AVCodec
return AVERROR_UNKNOWN;
}
- if (avctx->codec_id == AV_CODEC_ID_H264) {
- if (avctx->ticks_per_frame == 1) {
- if(h->avctx->time_base.den < INT_MAX/2) {
- h->avctx->time_base.den *= 2;
- } else
- h->avctx->time_base.num /= 2;
- }
- avctx->ticks_per_frame = 2;
- if (avctx->ticks_per_frame == 1)
- h->avctx->framerate.num *= 2;
++ if (avctx->ticks_per_frame == 1) {
++ if(h->avctx->time_base.den < INT_MAX/2) {
++ h->avctx->time_base.den *= 2;
++ } else
++ h->avctx->time_base.num /= 2;
+ }
+ avctx->ticks_per_frame = 2;
if (avctx->extradata_size > 0 && avctx->extradata) {
- ret = ff_h264_decode_extradata(avctx->extradata, avctx->extradata_size,
- &h->ps, &h->is_avc, &h->nal_length_size,
- avctx->err_recognition, avctx);
- if (ret < 0) {
- h264_decode_end(avctx);
- return ret;
- }
+ ret = ff_h264_decode_extradata(avctx->extradata, avctx->extradata_size,
+ &h->ps, &h->is_avc, &h->nal_length_size,
+ avctx->err_recognition, avctx);
+ if (ret < 0) {
+ h264_decode_end(avctx);
+ return ret;
+ }
}
if (h->ps.sps && h->ps.sps->bitstream_restriction_flag &&
1
0
ffmpeg | branch: master | Anton Khirnov <anton(a)khirnov.net> | Wed May 18 14:33:33 2016 +0200| [bc7f4268514624e1286ea76d27a89a56b4ee18e1] | committer: Anton Khirnov
h264: drop tests whether the codec id is AV_CODEC_ID_H264
Those are unused remnants of the old SVQ3 code.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bc7f4268514624e12…
---
libavcodec/h264_slice.c | 1 -
libavcodec/h264dec.c | 8 +++-----
2 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 376be27..eee222f 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -2111,7 +2111,6 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg)
sl->deblocking_filter = 0;
sl->is_complex = FRAME_MBAFF(h) || h->picture_structure != PICT_FRAME ||
- avctx->codec_id != AV_CODEC_ID_H264 ||
(CONFIG_GRAY && (h->flags & AV_CODEC_FLAG_GRAY));
if (h->ps.pps->cabac) {
diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index 52cb9ae..cc5bdca 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -371,11 +371,9 @@ av_cold int ff_h264_decode_init(AVCodecContext *avctx)
return AVERROR_UNKNOWN;
}
- if (avctx->codec_id == AV_CODEC_ID_H264) {
- if (avctx->ticks_per_frame == 1)
- h->avctx->framerate.num *= 2;
- avctx->ticks_per_frame = 2;
- }
+ if (avctx->ticks_per_frame == 1)
+ h->avctx->framerate.num *= 2;
+ avctx->ticks_per_frame = 2;
if (avctx->extradata_size > 0 && avctx->extradata) {
ret = ff_h264_decode_extradata(avctx->extradata, avctx->extradata_size,
1
0
ffmpeg | branch: master | James Almer <jamrial(a)gmail.com> | Mon Aug 1 16:46:57 2016 -0300| [fd4eb56528e1bf6529397051838a28d2a39d8e01] | committer: James Almer
Merge commit '8281cd5cb80582d668ce0848e0e035b383f161f6'
* commit '8281cd5cb80582d668ce0848e0e035b383f161f6':
h264_cabac: drop an always true condition
Merged-by: James Almer <jamrial(a)gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fd4eb56528e1bf652…
---
libavcodec/h264_cabac.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavcodec/h264_cabac.c b/libavcodec/h264_cabac.c
index 5776be9..fe83425 100644
--- a/libavcodec/h264_cabac.c
+++ b/libavcodec/h264_cabac.c
@@ -2358,7 +2358,7 @@ decode_intra_mb:
}
}
if (sl->top_type && !IS_8x8DCT(sl->top_type)){
- uint32_t top_empty = CABAC(h) && !IS_INTRA(mb_type) ? 0 : 0x40404040;
+ uint32_t top_empty = !IS_INTRA(mb_type) ? 0 : 0x40404040;
AV_WN32A(&nnz_cache[4+8* 0], top_empty);
AV_WN32A(&nnz_cache[4+8* 5], top_empty);
AV_WN32A(&nnz_cache[4+8*10], top_empty);
======================================================================
1
0
ffmpeg | branch: master | Anton Khirnov <anton(a)khirnov.net> | Wed May 18 14:31:48 2016 +0200| [8281cd5cb80582d668ce0848e0e035b383f161f6] | committer: Anton Khirnov
h264_cabac: drop an always true condition
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8281cd5cb80582d66…
---
libavcodec/h264_cabac.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavcodec/h264_cabac.c b/libavcodec/h264_cabac.c
index 203803f..ae1ef6b 100644
--- a/libavcodec/h264_cabac.c
+++ b/libavcodec/h264_cabac.c
@@ -2340,7 +2340,7 @@ decode_intra_mb:
}
}
if (sl->top_type && !IS_8x8DCT(sl->top_type)){
- uint32_t top_empty = CABAC(h) && !IS_INTRA(mb_type) ? 0 : 0x40404040;
+ uint32_t top_empty = !IS_INTRA(mb_type) ? 0 : 0x40404040;
AV_WN32A(&nnz_cache[4+8* 0], top_empty);
AV_WN32A(&nnz_cache[4+8* 5], top_empty);
AV_WN32A(&nnz_cache[4+8*10], top_empty);
1
0
ffmpeg | branch: master | James Almer <jamrial(a)gmail.com> | Mon Aug 1 15:11:05 2016 -0300| [f41048f6ec5671c2e09ae317cecc1e98ecc3c2ce] | committer: James Almer
Merge commit '5c2fb561d94fc51d76ab21d6f7cc5b6cc3aa599c'
* commit '5c2fb561d94fc51d76ab21d6f7cc5b6cc3aa599c':
h264: add H264_ prefix to the NAL unit types
Conflicts:
libavcodec/h264_parse.c
libavcodec/h264_parser.c
libavcodec/h264_slice.c
libavcodec/h264dec.c
Merged-by: James Almer <jamrial(a)gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f41048f6ec5671c2e…
---
libavcodec/h264.h | 28 +++++++++++------------
libavcodec/h264_parse.c | 4 ++--
libavcodec/h264_parser.c | 36 +++++++++++++++---------------
libavcodec/h264_refs.c | 2 +-
libavcodec/h264_slice.c | 12 +++++-----
libavcodec/h264dec.c | 50 +++++++++++++++++++++---------------------
libavcodec/omx.c | 2 +-
libavcodec/vaapi_encode_h264.c | 10 ++++-----
libavformat/mxfenc.c | 4 ++--
9 files changed, 74 insertions(+), 74 deletions(-)
diff --git a/libavcodec/h264.h b/libavcodec/h264.h
index bcdd4f6..86df5eb 100644
--- a/libavcodec/h264.h
+++ b/libavcodec/h264.h
@@ -28,20 +28,20 @@
/* NAL unit types */
enum {
- NAL_SLICE = 1,
- NAL_DPA = 2,
- NAL_DPB = 3,
- NAL_DPC = 4,
- NAL_IDR_SLICE = 5,
- NAL_SEI = 6,
- NAL_SPS = 7,
- NAL_PPS = 8,
- NAL_AUD = 9,
- NAL_END_SEQUENCE = 10,
- NAL_END_STREAM = 11,
- NAL_FILLER_DATA = 12,
- NAL_SPS_EXT = 13,
- NAL_AUXILIARY_SLICE = 19,
+ H264_NAL_SLICE = 1,
+ H264_NAL_DPA = 2,
+ H264_NAL_DPB = 3,
+ H264_NAL_DPC = 4,
+ H264_NAL_IDR_SLICE = 5,
+ H264_NAL_SEI = 6,
+ H264_NAL_SPS = 7,
+ H264_NAL_PPS = 8,
+ H264_NAL_AUD = 9,
+ H264_NAL_END_SEQUENCE = 10,
+ H264_NAL_END_STREAM = 11,
+ H264_NAL_FILLER_DATA = 12,
+ H264_NAL_SPS_EXT = 13,
+ H264_NAL_AUXILIARY_SLICE = 19,
};
#endif /* AVCODEC_H264_H */
diff --git a/libavcodec/h264_parse.c b/libavcodec/h264_parse.c
index da67149..1d4b1e4 100644
--- a/libavcodec/h264_parse.c
+++ b/libavcodec/h264_parse.c
@@ -346,12 +346,12 @@ static int decode_extradata_ps(const uint8_t *data, int size, H264ParamSets *ps,
for (i = 0; i < pkt.nb_nals; i++) {
H2645NAL *nal = &pkt.nals[i];
switch (nal->type) {
- case NAL_SPS:
+ case H264_NAL_SPS:
ret = ff_h264_decode_seq_parameter_set(&nal->gb, logctx, ps, 0);
if (ret < 0)
goto fail;
break;
- case NAL_PPS:
+ case H264_NAL_PPS:
ret = ff_h264_decode_picture_parameter_set(&nal->gb, logctx, ps,
nal->size_bits);
if (ret < 0)
diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c
index 20efdaa..0352b21 100644
--- a/libavcodec/h264_parser.c
+++ b/libavcodec/h264_parser.c
@@ -106,14 +106,14 @@ static int h264_find_frame_end(H264ParseContext *p, const uint8_t *buf,
state >>= 1; // 2->1, 1->0, 0->0
} else if (state <= 5) {
int nalu_type = buf[i] & 0x1F;
- if (nalu_type == NAL_SEI || nalu_type == NAL_SPS ||
- nalu_type == NAL_PPS || nalu_type == NAL_AUD) {
+ if (nalu_type == H264_NAL_SEI || nalu_type == H264_NAL_SPS ||
+ nalu_type == H264_NAL_PPS || nalu_type == H264_NAL_AUD) {
if (pc->frame_start_found) {
i++;
goto found;
}
- } else if (nalu_type == NAL_SLICE || nalu_type == NAL_DPA ||
- nalu_type == NAL_IDR_SLICE) {
+ } else if (nalu_type == H264_NAL_SLICE || nalu_type == H264_NAL_DPA ||
+ nalu_type == H264_NAL_IDR_SLICE) {
state += 8;
continue;
}
@@ -303,10 +303,10 @@ static inline int parse_nal_units(AVCodecParserContext *s,
state = buf[buf_index];
switch (state & 0x1f) {
- case NAL_SLICE:
- case NAL_IDR_SLICE:
+ case H264_NAL_SLICE:
+ case H264_NAL_IDR_SLICE:
// Do not walk the whole buffer just to decode slice header
- if ((state & 0x1f) == NAL_IDR_SLICE || ((state >> 5) & 0x3) == 0) {
+ if ((state & 0x1f) == H264_NAL_IDR_SLICE || ((state >> 5) & 0x3) == 0) {
/* IDR or disposable slice
* No need to decode many bytes because MMCOs shall not be present. */
if (src_length > 60)
@@ -332,17 +332,17 @@ static inline int parse_nal_units(AVCodecParserContext *s,
nal.type = get_bits(&nal.gb, 5);
switch (nal.type) {
- case NAL_SPS:
+ case H264_NAL_SPS:
ff_h264_decode_seq_parameter_set(&nal.gb, avctx, &p->ps, 0);
break;
- case NAL_PPS:
+ case H264_NAL_PPS:
ff_h264_decode_picture_parameter_set(&nal.gb, avctx, &p->ps,
nal.size_bits);
break;
- case NAL_SEI:
+ case H264_NAL_SEI:
ff_h264_sei_decode(&p->sei, &nal.gb, &p->ps, avctx);
break;
- case NAL_IDR_SLICE:
+ case H264_NAL_IDR_SLICE:
s->key_frame = 1;
p->poc.prev_frame_num = 0;
@@ -350,7 +350,7 @@ static inline int parse_nal_units(AVCodecParserContext *s,
p->poc.prev_poc_msb =
p->poc.prev_poc_lsb = 0;
/* fall through */
- case NAL_SLICE:
+ case H264_NAL_SLICE:
get_ue_golomb_long(&nal.gb); // skip first_mb_in_slice
slice_type = get_ue_golomb_31(&nal.gb);
s->pict_type = ff_h264_golomb_to_pict_type[slice_type % 5];
@@ -440,7 +440,7 @@ static inline int parse_nal_units(AVCodecParserContext *s,
}
}
- if (nal.type == NAL_IDR_SLICE)
+ if (nal.type == H264_NAL_IDR_SLICE)
get_ue_golomb_long(&nal.gb); /* idr_pic_id */
if (sps->poc_type == 0) {
p->poc.poc_lsb = get_bits(&nal.gb, sps->log2_max_poc_lsb);
@@ -469,7 +469,7 @@ static inline int parse_nal_units(AVCodecParserContext *s,
* FIXME: MMCO_RESET could appear in non-first slice.
* Maybe, we should parse all undisposable non-IDR slice of this
* picture until encountering MMCO_RESET in a slice of it. */
- if (nal.ref_idc && nal.type != NAL_IDR_SLICE) {
+ if (nal.ref_idc && nal.type != H264_NAL_IDR_SLICE) {
got_reset = scan_mmco_reset(s, &nal.gb, avctx);
if (got_reset < 0)
goto fail;
@@ -637,17 +637,17 @@ static int h264_split(AVCodecContext *avctx,
if ((state & 0xFFFFFF00) != 0x100)
break;
nalu_type = state & 0x1F;
- if (nalu_type == NAL_SPS) {
+ if (nalu_type == H264_NAL_SPS) {
has_sps = 1;
- } else if (nalu_type == NAL_PPS)
+ } else if (nalu_type == H264_NAL_PPS)
has_pps = 1;
/* else if (nalu_type == 0x01 ||
* nalu_type == 0x02 ||
* nalu_type == 0x05) {
* }
*/
- else if ((nalu_type != NAL_SEI || has_pps) &&
- nalu_type != NAL_AUD && nalu_type != NAL_SPS_EXT &&
+ else if ((nalu_type != H264_NAL_SEI || has_pps) &&
+ nalu_type != H264_NAL_AUD && nalu_type != H264_NAL_SPS_EXT &&
nalu_type != 0x0f) {
if (has_sps) {
while (ptr - 4 > buf && ptr[-5] == 0)
diff --git a/libavcodec/h264_refs.c b/libavcodec/h264_refs.c
index e66f69a..e760df1 100644
--- a/libavcodec/h264_refs.c
+++ b/libavcodec/h264_refs.c
@@ -828,7 +828,7 @@ int ff_h264_decode_ref_pic_marking(const H264Context *h, H264SliceContext *sl,
MMCO *mmco = sl->mmco;
int nb_mmco = 0;
- if (h->nal_unit_type == NAL_IDR_SLICE) { // FIXME fields
+ if (h->nal_unit_type == H264_NAL_IDR_SLICE) { // FIXME fields
skip_bits1(gb); // broken_link
if (get_bits1(gb)) {
mmco[0].opcode = MMCO_LONG;
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 9495b6e..fcc8443 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -1542,7 +1542,7 @@ static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl,
sl->slice_type = slice_type;
sl->slice_type_nos = slice_type & 3;
- if (nal->type == NAL_IDR_SLICE &&
+ if (nal->type == H264_NAL_IDR_SLICE &&
sl->slice_type_nos != AV_PICTURE_TYPE_I) {
av_log(h->avctx, AV_LOG_ERROR, "A non-intra slice in an IDR NAL unit.\n");
return AVERROR_INVALIDDATA;
@@ -1605,7 +1605,7 @@ static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl,
sl->max_pic_num = 1 << (sps->log2_max_frame_num + 1);
}
- if (nal->type == NAL_IDR_SLICE)
+ if (nal->type == H264_NAL_IDR_SLICE)
get_ue_golomb_long(&sl->gb); /* idr_pic_id */
if (sps->poc_type == 0) {
@@ -1758,7 +1758,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl,
h->current_slice = 0;
if (ret < 0)
return ret;
- } else if (h->cur_pic_ptr && !FIELD_PICTURE(h) && !h->first_field && h->nal_unit_type == NAL_IDR_SLICE) {
+ } else if (h->cur_pic_ptr && !FIELD_PICTURE(h) && !h->first_field && h->nal_unit_type == H264_NAL_IDR_SLICE) {
av_log(h, AV_LOG_WARNING, "Broken frame packetizing\n");
ret = ff_h264_field_end(h, h->slice_ctx, 1);
h->current_slice = 0;
@@ -1788,7 +1788,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl,
(h->avctx->skip_frame >= AVDISCARD_NONREF && !h->nal_ref_idc) ||
(h->avctx->skip_frame >= AVDISCARD_BIDIR && sl->slice_type_nos == AV_PICTURE_TYPE_B) ||
(h->avctx->skip_frame >= AVDISCARD_NONINTRA && sl->slice_type_nos != AV_PICTURE_TYPE_I) ||
- (h->avctx->skip_frame >= AVDISCARD_NONKEY && h->nal_unit_type != NAL_IDR_SLICE && h->sei.recovery_point.recovery_frame_cnt < 0) ||
+ (h->avctx->skip_frame >= AVDISCARD_NONKEY && h->nal_unit_type != H264_NAL_IDR_SLICE && h->sei.recovery_point.recovery_frame_cnt < 0) ||
h->avctx->skip_frame >= AVDISCARD_ALL) {
return SLICE_SKIPED;
}
@@ -1861,7 +1861,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl,
if (h->avctx->skip_loop_filter >= AVDISCARD_ALL ||
(h->avctx->skip_loop_filter >= AVDISCARD_NONKEY &&
- h->nal_unit_type != NAL_IDR_SLICE) ||
+ h->nal_unit_type != H264_NAL_IDR_SLICE) ||
(h->avctx->skip_loop_filter >= AVDISCARD_NONINTRA &&
sl->slice_type_nos != AV_PICTURE_TYPE_I) ||
(h->avctx->skip_loop_filter >= AVDISCARD_BIDIR &&
@@ -1938,7 +1938,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl,
sl->mb_y * h->mb_width + sl->mb_x,
av_get_picture_type_char(sl->slice_type),
sl->slice_type_fixed ? " fix" : "",
- nal->type == NAL_IDR_SLICE ? " IDR" : "",
+ nal->type == H264_NAL_IDR_SLICE ? " IDR" : "",
h->poc.frame_num,
h->cur_pic_ptr->field_poc[0],
h->cur_pic_ptr->field_poc[1],
diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index 91bc38d..d944a8c 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -674,13 +674,13 @@ static int get_last_needed_nal(H264Context *h)
* which splits NALs strangely if so, when frame threading we
* can't start the next thread until we've read all of them */
switch (nal->type) {
- case NAL_SPS:
- case NAL_PPS:
+ case H264_NAL_SPS:
+ case H264_NAL_PPS:
nals_needed = i;
break;
- case NAL_DPA:
- case NAL_IDR_SLICE:
- case NAL_SLICE:
+ case H264_NAL_DPA:
+ case H264_NAL_IDR_SLICE:
+ case H264_NAL_SLICE:
ret = init_get_bits8(&gb, nal->data + 1, (nal->size - 1));
if (ret < 0)
return ret;
@@ -768,7 +768,7 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size)
int err;
if (avctx->skip_frame >= AVDISCARD_NONREF &&
- nal->ref_idc == 0 && nal->type != NAL_SEI)
+ nal->ref_idc == 0 && nal->type != H264_NAL_SEI)
continue;
again:
@@ -778,14 +778,14 @@ again:
err = 0;
switch (nal->type) {
- case NAL_IDR_SLICE:
+ case H264_NAL_IDR_SLICE:
if ((nal->data[1] & 0xFC) == 0x98) {
av_log(h->avctx, AV_LOG_ERROR, "Invalid inter IDR frame\n");
h->next_outputed_poc = INT_MIN;
ret = -1;
goto end;
}
- if (nal->type != NAL_IDR_SLICE) {
+ if (nal->type != H264_NAL_IDR_SLICE) {
av_log(h->avctx, AV_LOG_ERROR,
"Invalid mix of idr and non-idr slices\n");
ret = -1;
@@ -801,7 +801,7 @@ again:
}
idr_cleared = 1;
h->has_recovery_point = 1;
- case NAL_SLICE:
+ case H264_NAL_SLICE:
sl->gb = nal->gb;
if ((err = ff_h264_decode_slice_header(h, sl, nal)))
@@ -822,16 +822,16 @@ again:
}
}
- h->cur_pic_ptr->f->key_frame |= (nal->type == NAL_IDR_SLICE);
+ h->cur_pic_ptr->f->key_frame |= (nal->type == H264_NAL_IDR_SLICE);
- if (nal->type == NAL_IDR_SLICE ||
+ if (nal->type == H264_NAL_IDR_SLICE ||
(h->recovery_frame == h->poc.frame_num && nal->ref_idc)) {
h->recovery_frame = -1;
h->cur_pic_ptr->recovered = 1;
}
// If we have an IDR, all frames after it in decoded order are
// "recovered".
- if (nal->type == NAL_IDR_SLICE)
+ if (nal->type == H264_NAL_IDR_SLICE)
h->frame_recovered |= FRAME_RECOVERED_IDR;
#if 1
h->cur_pic_ptr->recovered |= h->frame_recovered;
@@ -874,12 +874,12 @@ again:
context_count++;
}
break;
- case NAL_DPA:
- case NAL_DPB:
- case NAL_DPC:
+ case H264_NAL_DPA:
+ case H264_NAL_DPB:
+ case H264_NAL_DPC:
avpriv_request_sample(avctx, "data partitioning");
break;
- case NAL_SEI:
+ case H264_NAL_SEI:
ret = ff_h264_sei_decode(&h->sei, &nal->gb, &h->ps, avctx);
h->has_recovery_point = h->has_recovery_point || h->sei.recovery_point.recovery_frame_cnt != -1;
if (avctx->debug & FF_DEBUG_GREEN_MD)
@@ -892,7 +892,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
goto end;
break;
- case NAL_SPS: {
+ case H264_NAL_SPS: {
GetBitContext tmp_gb = nal->gb;
if (ff_h264_decode_seq_parameter_set(&tmp_gb, avctx, &h->ps, 0) >= 0)
break;
@@ -904,18 +904,18 @@ FF_ENABLE_DEPRECATION_WARNINGS
ff_h264_decode_seq_parameter_set(&nal->gb, avctx, &h->ps, 1);
break;
}
- case NAL_PPS:
+ case H264_NAL_PPS:
ret = ff_h264_decode_picture_parameter_set(&nal->gb, avctx, &h->ps,
nal->size_bits);
if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
goto end;
break;
- case NAL_AUD:
- case NAL_END_SEQUENCE:
- case NAL_END_STREAM:
- case NAL_FILLER_DATA:
- case NAL_SPS_EXT:
- case NAL_AUXILIARY_SLICE:
+ case H264_NAL_AUD:
+ case H264_NAL_END_SEQUENCE:
+ case H264_NAL_END_STREAM:
+ case H264_NAL_FILLER_DATA:
+ case H264_NAL_SPS_EXT:
+ case H264_NAL_AUXILIARY_SLICE:
break;
default:
av_log(avctx, AV_LOG_DEBUG, "Unknown NAL code: %d (%d bits)\n",
@@ -1157,7 +1157,7 @@ static int h264_decode_frame(AVCodecContext *avctx, void *data,
if (buf_index < 0)
return AVERROR_INVALIDDATA;
- if (!h->cur_pic_ptr && h->nal_unit_type == NAL_END_SEQUENCE) {
+ if (!h->cur_pic_ptr && h->nal_unit_type == H264_NAL_END_SEQUENCE) {
av_assert0(buf_index <= buf_size);
goto out;
}
diff --git a/libavcodec/omx.c b/libavcodec/omx.c
index 1b2ae0d..c1b6fb9 100644
--- a/libavcodec/omx.c
+++ b/libavcodec/omx.c
@@ -703,7 +703,7 @@ static av_cold int omx_encode_init(AVCodecContext *avctx)
nals[avctx->extradata[i + 4] & 0x1f]++;
}
}
- if (nals[NAL_SPS] && nals[NAL_PPS])
+ if (nals[H264_NAL_SPS] && nals[H264_NAL_PPS])
break;
} else {
if (avctx->extradata_size > 0)
diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
index d576ede..979cf37 100644
--- a/libavcodec/vaapi_encode_h264.c
+++ b/libavcodec/vaapi_encode_h264.c
@@ -283,7 +283,7 @@ static void vaapi_encode_h264_write_sps(PutBitContext *pbc,
VAAPIEncodeH264MiscSequenceParams *mseq = &priv->misc_sequence_params;
int i;
- vaapi_encode_h264_write_nal_header(pbc, NAL_SPS, 3);
+ vaapi_encode_h264_write_nal_header(pbc, H264_NAL_SPS, 3);
u(8, mseq_var(profile_idc));
u(1, mseq_var(constraint_set0_flag));
@@ -368,7 +368,7 @@ static void vaapi_encode_h264_write_pps(PutBitContext *pbc,
VAAPIEncodeH264Context *priv = ctx->priv_data;
VAAPIEncodeH264MiscSequenceParams *mseq = &priv->misc_sequence_params;
- vaapi_encode_h264_write_nal_header(pbc, NAL_PPS, 3);
+ vaapi_encode_h264_write_nal_header(pbc, H264_NAL_PPS, 3);
ue(vpic_var(pic_parameter_set_id));
ue(vpic_var(seq_parameter_set_id));
@@ -642,7 +642,7 @@ static void vaapi_encode_h264_write_sei(PutBitContext *pbc,
VAAPIEncodeContext *ctx,
VAAPIEncodePicture *pic) = NULL;
- vaapi_encode_h264_write_nal_header(pbc, NAL_SEI, 0);
+ vaapi_encode_h264_write_nal_header(pbc, H264_NAL_SEI, 0);
for (payload_type = 0; payload_type < 64; payload_type++) {
switch (payload_type) {
@@ -1010,9 +1010,9 @@ static int vaapi_encode_h264_init_slice_params(AVCodecContext *avctx,
mslice = &pslice->misc_slice_params;
if (pic->type == PICTURE_TYPE_IDR)
- mslice->nal_unit_type = NAL_IDR_SLICE;
+ mslice->nal_unit_type = H264_NAL_IDR_SLICE;
else
- mslice->nal_unit_type = NAL_SLICE;
+ mslice->nal_unit_type = H264_NAL_SLICE;
switch (pic->type) {
case PICTURE_TYPE_IDR:
diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index 80318b8..ffd0bf2 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -1860,11 +1860,11 @@ static int mxf_parse_h264_frame(AVFormatContext *s, AVStream *st,
break;
--buf;
switch (state & 0x1f) {
- case NAL_SPS:
+ case H264_NAL_SPS:
st->codecpar->profile = buf[1];
e->flags |= 0x40;
break;
- case NAL_PPS:
+ case H264_NAL_PPS:
if (e->flags & 0x40) { // sequence header present
e->flags |= 0x80; // random access
extra_size = 0;
======================================================================
diff --cc libavcodec/h264_parse.c
index da67149,d694558..1d4b1e4
--- a/libavcodec/h264_parse.c
+++ b/libavcodec/h264_parse.c
@@@ -346,8 -330,8 +346,8 @@@ static int decode_extradata_ps(const ui
for (i = 0; i < pkt.nb_nals; i++) {
H2645NAL *nal = &pkt.nals[i];
switch (nal->type) {
- case NAL_SPS:
+ case H264_NAL_SPS:
- ret = ff_h264_decode_seq_parameter_set(&nal->gb, logctx, ps);
+ ret = ff_h264_decode_seq_parameter_set(&nal->gb, logctx, ps, 0);
if (ret < 0)
goto fail;
break;
diff --cc libavcodec/h264_parser.c
index 20efdaa,b4da123..0352b21
--- a/libavcodec/h264_parser.c
+++ b/libavcodec/h264_parser.c
@@@ -112,29 -89,20 +112,29 @@@ static int h264_find_frame_end(H264Pars
i++;
goto found;
}
- } else if (nalu_type == NAL_SLICE || nalu_type == NAL_DPA ||
- nalu_type == NAL_IDR_SLICE) {
+ } else if (nalu_type == H264_NAL_SLICE || nalu_type == H264_NAL_DPA ||
+ nalu_type == H264_NAL_IDR_SLICE) {
+ state += 8;
+ continue;
+ }
+ state = 7;
+ } else {
+ p->parse_history[p->parse_history_count++] = buf[i];
+ if (p->parse_history_count > 5) {
+ unsigned int mb, last_mb = p->parse_last_mb;
+ GetBitContext gb;
+
+ init_get_bits(&gb, p->parse_history, 8*p->parse_history_count);
+ p->parse_history_count = 0;
+ mb= get_ue_golomb_long(&gb);
+ p->parse_last_mb = mb;
if (pc->frame_start_found) {
- state += 8;
- continue;
+ if (mb <= last_mb)
+ goto found;
} else
pc->frame_start_found = 1;
+ state = 7;
}
- state = 7;
- } else {
- // first_mb_in_slice is 0, probably the first nal of a new slice
- if (buf[i] & 0x80)
- goto found;
- state = 7;
}
}
pc->state = state;
@@@ -281,32 -225,19 +281,32 @@@ static inline int parse_nal_units(AVCod
if (!buf_size)
return 0;
+ buf_index = 0;
+ next_avc = p->is_avc ? 0 : buf_size;
for (;;) {
const SPS *sps;
- int src_length, consumed;
- buf = avpriv_find_start_code(buf, buf_end, &state);
- if (buf >= buf_end)
- break;
- --buf;
- src_length = buf_end - buf;
+ int src_length, consumed, nalsize = 0;
+
+ if (buf_index >= next_avc) {
+ nalsize = get_avc_nalsize(p, buf, buf_size, &buf_index, avctx);
+ if (nalsize < 0)
+ break;
+ next_avc = buf_index + nalsize;
+ } else {
+ buf_index = find_start_code(buf, buf_size, buf_index, next_avc);
+ if (buf_index >= buf_size)
+ break;
+ if (buf_index >= next_avc)
+ continue;
+ }
+ src_length = next_avc - buf_index;
+
+ state = buf[buf_index];
switch (state & 0x1f) {
- case NAL_SLICE:
- case NAL_IDR_SLICE:
+ case H264_NAL_SLICE:
+ case H264_NAL_IDR_SLICE:
// Do not walk the whole buffer just to decode slice header
- if ((state & 0x1f) == NAL_IDR_SLICE || ((state >> 5) & 0x3) == 0) {
+ if ((state & 0x1f) == H264_NAL_IDR_SLICE || ((state >> 5) & 0x3) == 0) {
/* IDR or disposable slice
* No need to decode many bytes because MMCOs shall not be present. */
if (src_length > 60)
@@@ -332,10 -262,10 +332,10 @@@
nal.type = get_bits(&nal.gb, 5);
switch (nal.type) {
- case NAL_SPS:
+ case H264_NAL_SPS:
- ff_h264_decode_seq_parameter_set(&nal.gb, avctx, &p->ps);
+ ff_h264_decode_seq_parameter_set(&nal.gb, avctx, &p->ps, 0);
break;
- case NAL_PPS:
+ case H264_NAL_PPS:
ff_h264_decode_picture_parameter_set(&nal.gb, avctx, &p->ps,
nal.size_bits);
break;
@@@ -350,8 -280,8 +350,8 @@@
p->poc.prev_poc_msb =
p->poc.prev_poc_lsb = 0;
/* fall through */
- case NAL_SLICE:
+ case H264_NAL_SLICE:
- get_ue_golomb(&nal.gb); // skip first_mb_in_slice
+ get_ue_golomb_long(&nal.gb); // skip first_mb_in_slice
slice_type = get_ue_golomb_31(&nal.gb);
s->pict_type = ff_h264_golomb_to_pict_type[slice_type % 5];
if (p->sei.recovery_point.recovery_frame_cnt >= 0) {
@@@ -440,8 -353,8 +440,8 @@@
}
}
- if (nal.type == NAL_IDR_SLICE)
+ if (nal.type == H264_NAL_IDR_SLICE)
- get_ue_golomb(&nal.gb); /* idr_pic_id */
+ get_ue_golomb_long(&nal.gb); /* idr_pic_id */
if (sps->poc_type == 0) {
p->poc.poc_lsb = get_bits(&nal.gb, sps->log2_max_poc_lsb);
@@@ -626,37 -534,31 +626,37 @@@ static int h264_parse(AVCodecParserCont
static int h264_split(AVCodecContext *avctx,
const uint8_t *buf, int buf_size)
{
- int i;
uint32_t state = -1;
int has_sps = 0;
+ int has_pps = 0;
+ const uint8_t *ptr = buf, *end = buf + buf_size;
+ int nalu_type;
- for (i = 0; i <= buf_size; i++) {
- if ((state & 0xFFFFFF1F) == 0x107)
+ while (ptr < end) {
+ ptr = avpriv_find_start_code(ptr, end, &state);
+ if ((state & 0xFFFFFF00) != 0x100)
+ break;
+ nalu_type = state & 0x1F;
- if (nalu_type == NAL_SPS) {
++ if (nalu_type == H264_NAL_SPS) {
has_sps = 1;
- } else if (nalu_type == NAL_PPS)
- /* if((state&0xFFFFFF1F) == 0x101 ||
- * (state&0xFFFFFF1F) == 0x102 ||
- * (state&0xFFFFFF1F) == 0x105) {
++ } else if (nalu_type == H264_NAL_PPS)
+ has_pps = 1;
+ /* else if (nalu_type == 0x01 ||
+ * nalu_type == 0x02 ||
+ * nalu_type == 0x05) {
* }
*/
- else if ((nalu_type != NAL_SEI || has_pps) &&
- nalu_type != NAL_AUD && nalu_type != NAL_SPS_EXT &&
- if ((state & 0xFFFFFF00) == 0x100 && (state & 0xFFFFFF1F) != 0x106 &&
- (state & 0xFFFFFF1F) != 0x107 && (state & 0xFFFFFF1F) != 0x108 &&
- (state & 0xFFFFFF1F) != 0x109 && (state & 0xFFFFFF1F) != 0x10d &&
- (state & 0xFFFFFF1F) != 0x10f) {
++ else if ((nalu_type != H264_NAL_SEI || has_pps) &&
++ nalu_type != H264_NAL_AUD && nalu_type != H264_NAL_SPS_EXT &&
+ nalu_type != 0x0f) {
if (has_sps) {
- while (i > 4 && buf[i - 5] == 0)
- i--;
- return i - 4;
+ while (ptr - 4 > buf && ptr[-5] == 0)
+ ptr--;
+ return ptr - 4 - buf;
}
}
- if (i < buf_size)
- state = (state << 8) | buf[i];
}
+
return 0;
}
diff --cc libavcodec/h264_slice.c
index 9495b6e,376be27..fcc8443
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@@ -1605,8 -1427,8 +1605,8 @@@ static int h264_slice_header_parse(cons
sl->max_pic_num = 1 << (sps->log2_max_frame_num + 1);
}
- if (nal->type == NAL_IDR_SLICE)
+ if (nal->type == H264_NAL_IDR_SLICE)
- get_ue_golomb(&sl->gb); /* idr_pic_id */
+ get_ue_golomb_long(&sl->gb); /* idr_pic_id */
if (sps->poc_type == 0) {
sl->poc_lsb = get_bits(&sl->gb, sps->log2_max_poc_lsb);
@@@ -1735,62 -1556,26 +1735,62 @@@ int ff_h264_decode_slice_header(H264Con
if (ret < 0)
return ret;
- if (!h->setup_finished) {
- if (sl->first_mb_addr == 0) { // FIXME better field boundary detection
- if (h->current_slice && h->cur_pic_ptr && FIELD_PICTURE(h)) {
- ff_h264_field_end(h, sl, 1);
- }
+ if (sl->first_mb_addr == 0 || !h->current_slice) {
+ if (h->setup_finished) {
+ av_log(h->avctx, AV_LOG_ERROR, "Too many fields\n");
+ return AVERROR_INVALIDDATA;
+ }
+ }
- h->current_slice = 0;
- if (!h->first_field) {
- if (h->cur_pic_ptr && !h->droppable) {
- ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX,
- h->picture_structure == PICT_BOTTOM_FIELD);
+ if (sl->first_mb_addr == 0) { // FIXME better field boundary detection
+ if (h->current_slice) {
+ if (h->max_contexts > 1) {
+ if (!h->single_decode_warning) {
+ av_log(h->avctx, AV_LOG_WARNING, "Cannot decode multiple access units as slice threads\n");
+ h->single_decode_warning = 1;
}
+ h->max_contexts = 1;
+ return SLICE_SINGLETHREAD;
+ }
+
+ if (h->cur_pic_ptr && FIELD_PICTURE(h) && h->first_field) {
+ ret = ff_h264_field_end(h, h->slice_ctx, 1);
+ h->current_slice = 0;
+ if (ret < 0)
+ return ret;
- } else if (h->cur_pic_ptr && !FIELD_PICTURE(h) && !h->first_field && h->nal_unit_type == NAL_IDR_SLICE) {
++ } else if (h->cur_pic_ptr && !FIELD_PICTURE(h) && !h->first_field && h->nal_unit_type == H264_NAL_IDR_SLICE) {
+ av_log(h, AV_LOG_WARNING, "Broken frame packetizing\n");
+ ret = ff_h264_field_end(h, h->slice_ctx, 1);
+ h->current_slice = 0;
+ ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX, 0);
+ ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX, 1);
h->cur_pic_ptr = NULL;
+ if (ret < 0)
+ return ret;
+ } else
+ return AVERROR_INVALIDDATA;
+ }
+
+ if (!h->first_field) {
+ if (h->cur_pic_ptr && !h->droppable) {
+ ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX,
+ h->picture_structure == PICT_BOTTOM_FIELD);
}
+ h->cur_pic_ptr = NULL;
}
+ }
- if (h->current_slice == 0) {
- ret = h264_field_start(h, sl, nal);
- if (ret < 0)
- return ret;
+ if (!h->current_slice)
+ av_assert0(sl == h->slice_ctx);
+
+ if (h->current_slice == 0 && !h->first_field) {
+ if (
+ (h->avctx->skip_frame >= AVDISCARD_NONREF && !h->nal_ref_idc) ||
+ (h->avctx->skip_frame >= AVDISCARD_BIDIR && sl->slice_type_nos == AV_PICTURE_TYPE_B) ||
+ (h->avctx->skip_frame >= AVDISCARD_NONINTRA && sl->slice_type_nos != AV_PICTURE_TYPE_I) ||
- (h->avctx->skip_frame >= AVDISCARD_NONKEY && h->nal_unit_type != NAL_IDR_SLICE && h->sei.recovery_point.recovery_frame_cnt < 0) ||
++ (h->avctx->skip_frame >= AVDISCARD_NONKEY && h->nal_unit_type != H264_NAL_IDR_SLICE && h->sei.recovery_point.recovery_frame_cnt < 0) ||
+ h->avctx->skip_frame >= AVDISCARD_ALL) {
+ return SLICE_SKIPED;
}
}
@@@ -1861,8 -1631,6 +1861,8 @@@
if (h->avctx->skip_loop_filter >= AVDISCARD_ALL ||
(h->avctx->skip_loop_filter >= AVDISCARD_NONKEY &&
- h->nal_unit_type != NAL_IDR_SLICE) ||
++ h->nal_unit_type != H264_NAL_IDR_SLICE) ||
+ (h->avctx->skip_loop_filter >= AVDISCARD_NONINTRA &&
sl->slice_type_nos != AV_PICTURE_TYPE_I) ||
(h->avctx->skip_loop_filter >= AVDISCARD_BIDIR &&
sl->slice_type_nos == AV_PICTURE_TYPE_B) ||
diff --cc libavcodec/h264dec.c
index 91bc38d,52cb9ae..d944a8c
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@@ -674,22 -639,16 +674,22 @@@ static int get_last_needed_nal(H264Cont
* which splits NALs strangely if so, when frame threading we
* can't start the next thread until we've read all of them */
switch (nal->type) {
- case NAL_SPS:
- case NAL_PPS:
+ case H264_NAL_SPS:
+ case H264_NAL_PPS:
nals_needed = i;
break;
- case NAL_DPA:
- case NAL_IDR_SLICE:
- case NAL_SLICE:
+ case H264_NAL_DPA:
+ case H264_NAL_IDR_SLICE:
+ case H264_NAL_SLICE:
- init_get_bits(&gb, nal->data + 1, (nal->size - 1) * 8);
- if (!get_ue_golomb(&gb))
+ ret = init_get_bits8(&gb, nal->data + 1, (nal->size - 1));
+ if (ret < 0)
+ return ret;
+ if (!get_ue_golomb_long(&gb) || // first_mb_in_slice
+ !first_slice ||
+ first_slice != nal->type)
nals_needed = i;
+ if (!first_slice)
+ first_slice = nal->type;
}
}
@@@ -768,76 -686,46 +768,76 @@@ static int decode_nal_units(H264Contex
int err;
if (avctx->skip_frame >= AVDISCARD_NONREF &&
- nal->ref_idc == 0 && nal->type != NAL_SEI)
+ nal->ref_idc == 0 && nal->type != H264_NAL_SEI)
continue;
+again:
// FIXME these should stop being context-global variables
h->nal_ref_idc = nal->ref_idc;
h->nal_unit_type = nal->type;
err = 0;
switch (nal->type) {
- case NAL_IDR_SLICE:
+ case H264_NAL_IDR_SLICE:
+ if ((nal->data[1] & 0xFC) == 0x98) {
+ av_log(h->avctx, AV_LOG_ERROR, "Invalid inter IDR frame\n");
+ h->next_outputed_poc = INT_MIN;
+ ret = -1;
+ goto end;
+ }
- if (nal->type != NAL_IDR_SLICE) {
+ if (nal->type != H264_NAL_IDR_SLICE) {
av_log(h->avctx, AV_LOG_ERROR,
"Invalid mix of idr and non-idr slices\n");
ret = -1;
goto end;
}
- idr(h); // FIXME ensure we don't lose some frames if there is reordering
+ if(!idr_cleared) {
+ if (h->current_slice && (avctx->active_thread_type & FF_THREAD_SLICE)) {
+ av_log(h, AV_LOG_ERROR, "invalid mixed IDR / non IDR frames cannot be decoded in slice multithreading mode\n");
+ ret = AVERROR_INVALIDDATA;
+ goto end;
+ }
+ idr(h); // FIXME ensure we don't lose some frames if there is reordering
+ }
+ idr_cleared = 1;
+ h->has_recovery_point = 1;
- case NAL_SLICE:
+ case H264_NAL_SLICE:
sl->gb = nal->gb;
if ((err = ff_h264_decode_slice_header(h, sl, nal)))
break;
- if (h->sei.recovery_point.recovery_frame_cnt >= 0 && h->recovery_frame < 0) {
- h->recovery_frame = (h->poc.frame_num + h->sei.recovery_point.recovery_frame_cnt) &
- ((1 << h->ps.sps->log2_max_frame_num) - 1);
+ if (h->sei.recovery_point.recovery_frame_cnt >= 0) {
+ const int sei_recovery_frame_cnt = h->sei.recovery_point.recovery_frame_cnt;
+
+ if (h->poc.frame_num != sei_recovery_frame_cnt || sl->slice_type_nos != AV_PICTURE_TYPE_I)
+ h->valid_recovery_point = 1;
+
+ if ( h->recovery_frame < 0
+ || av_mod_uintp2(h->recovery_frame - h->poc.frame_num, h->ps.sps->log2_max_frame_num) > sei_recovery_frame_cnt) {
+ h->recovery_frame = av_mod_uintp2(h->poc.frame_num + sei_recovery_frame_cnt, h->ps.sps->log2_max_frame_num);
+
+ if (!h->valid_recovery_point)
+ h->recovery_frame = h->poc.frame_num;
+ }
}
- h->cur_pic_ptr->f->key_frame |= (nal->type == NAL_IDR_SLICE);
- h->cur_pic_ptr->f->key_frame |=
- (nal->type == H264_NAL_IDR_SLICE) || (h->sei.recovery_point.recovery_frame_cnt >= 0);
++ h->cur_pic_ptr->f->key_frame |= (nal->type == H264_NAL_IDR_SLICE);
- if (nal->type == NAL_IDR_SLICE ||
- if (nal->type == H264_NAL_IDR_SLICE || h->recovery_frame == h->poc.frame_num) {
++ if (nal->type == H264_NAL_IDR_SLICE ||
+ (h->recovery_frame == h->poc.frame_num && nal->ref_idc)) {
h->recovery_frame = -1;
h->cur_pic_ptr->recovered = 1;
}
// If we have an IDR, all frames after it in decoded order are
// "recovered".
- if (nal->type == NAL_IDR_SLICE)
+ if (nal->type == H264_NAL_IDR_SLICE)
h->frame_recovered |= FRAME_RECOVERED_IDR;
+#if 1
+ h->cur_pic_ptr->recovered |= h->frame_recovered;
+#else
h->cur_pic_ptr->recovered |= !!(h->frame_recovered & FRAME_RECOVERED_IDR);
+#endif
if (h->current_slice == 1) {
if (!(avctx->flags2 & AV_CODEC_FLAG2_CHUNKS))
@@@ -874,37 -751,24 +874,37 @@@
context_count++;
}
break;
- case NAL_DPA:
- case NAL_DPB:
- case NAL_DPC:
+ case H264_NAL_DPA:
+ case H264_NAL_DPB:
+ case H264_NAL_DPC:
avpriv_request_sample(avctx, "data partitioning");
- ret = AVERROR(ENOSYS);
- goto end;
break;
- case NAL_SEI:
+ case H264_NAL_SEI:
ret = ff_h264_sei_decode(&h->sei, &nal->gb, &h->ps, avctx);
+ h->has_recovery_point = h->has_recovery_point || h->sei.recovery_point.recovery_frame_cnt != -1;
+ if (avctx->debug & FF_DEBUG_GREEN_MD)
+ debug_green_metadata(&h->sei.green_metadata, h->avctx);
+#if FF_API_AFD
+FF_DISABLE_DEPRECATION_WARNINGS
+ h->avctx->dtg_active_format = h->sei.afd.active_format_description;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif /* FF_API_AFD */
if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
goto end;
break;
- case NAL_SPS: {
- case H264_NAL_SPS:
- ret = ff_h264_decode_seq_parameter_set(&nal->gb, avctx, &h->ps);
- if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
- goto end;
++ case H264_NAL_SPS: {
+ GetBitContext tmp_gb = nal->gb;
+ if (ff_h264_decode_seq_parameter_set(&tmp_gb, avctx, &h->ps, 0) >= 0)
+ break;
+ av_log(h->avctx, AV_LOG_DEBUG,
+ "SPS decoding failure, trying again with the complete NAL\n");
+ init_get_bits8(&tmp_gb, nal->raw_data + 1, nal->raw_size - 1);
+ if (ff_h264_decode_seq_parameter_set(&tmp_gb, avctx, &h->ps, 0) >= 0)
+ break;
+ ff_h264_decode_seq_parameter_set(&nal->gb, avctx, &h->ps, 1);
break;
+ }
- case NAL_PPS:
+ case H264_NAL_PPS:
ret = ff_h264_decode_picture_parameter_set(&nal->gb, avctx, &h->ps,
nal->size_bits);
if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
@@@ -1157,8 -912,8 +1157,8 @@@ static int h264_decode_frame(AVCodecCon
if (buf_index < 0)
return AVERROR_INVALIDDATA;
- if (!h->cur_pic_ptr && h->nal_unit_type == NAL_END_SEQUENCE) {
+ if (!h->cur_pic_ptr && h->nal_unit_type == H264_NAL_END_SEQUENCE) {
- buf_size = 0;
+ av_assert0(buf_index <= buf_size);
goto out;
}
diff --cc libavformat/mxfenc.c
index 80318b8,1431fc6..ffd0bf2
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@@ -1656,255 -1280,6 +1656,255 @@@ static int mxf_write_partition(AVFormat
return 0;
}
+static int mxf_parse_dnxhd_frame(AVFormatContext *s, AVStream *st,
+AVPacket *pkt)
+{
+ MXFContext *mxf = s->priv_data;
+ MXFStreamContext *sc = st->priv_data;
+ int i, cid;
+ uint8_t* header_cid;
+ int frame_size = 0;
+
+ if (mxf->header_written)
+ return 1;
+
+ if (pkt->size < 43)
+ return -1;
+
+ header_cid = pkt->data + 0x28;
+ cid = header_cid[0] << 24 | header_cid[1] << 16 | header_cid[2] << 8 | header_cid[3];
+
+ if ((frame_size = avpriv_dnxhd_get_frame_size(cid)) < 0)
+ return -1;
+ if ((sc->interlaced = avpriv_dnxhd_get_interlaced(cid)) < 0)
+ return AVERROR_INVALIDDATA;
+
+ switch (cid) {
+ case 1235:
+ sc->index = 24;
+ sc->component_depth = 10;
+ break;
+ case 1237:
+ sc->index = 25;
+ break;
+ case 1238:
+ sc->index = 26;
+ break;
+ case 1241:
+ sc->index = 27;
+ sc->component_depth = 10;
+ break;
+ case 1242:
+ sc->index = 28;
+ break;
+ case 1243:
+ sc->index = 29;
+ break;
+ case 1250:
+ sc->index = 30;
+ sc->component_depth = 10;
+ break;
+ case 1251:
+ sc->index = 31;
+ break;
+ case 1252:
+ sc->index = 32;
+ break;
+ case 1253:
+ sc->index = 33;
+ break;
+ default:
+ return -1;
+ }
+
+ sc->codec_ul = &mxf_essence_container_uls[sc->index].codec_ul;
+ sc->aspect_ratio = (AVRational){ 16, 9 };
+
+ if(s->oformat == &ff_mxf_opatom_muxer){
+ mxf->edit_unit_byte_count = frame_size;
+ return 1;
+ }
+
+ mxf->edit_unit_byte_count = KAG_SIZE;
+ for (i = 0; i < s->nb_streams; i++) {
+ AVStream *st = s->streams[i];
+ MXFStreamContext *sc = st->priv_data;
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+ mxf->edit_unit_byte_count += 16 + 4 + sc->aic.samples[0]*sc->aic.sample_size;
+ mxf->edit_unit_byte_count += klv_fill_size(mxf->edit_unit_byte_count);
+ } else if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+ mxf->edit_unit_byte_count += 16 + 4 + frame_size;
+ mxf->edit_unit_byte_count += klv_fill_size(mxf->edit_unit_byte_count);
+ }
+ }
+
+ return 1;
+}
+
+static int mxf_parse_dv_frame(AVFormatContext *s, AVStream *st, AVPacket *pkt)
+{
+ MXFContext *mxf = s->priv_data;
+ MXFStreamContext *sc = st->priv_data;
+ uint8_t *vs_pack, *vsc_pack;
+ int i, ul_index, frame_size, stype, pal;
+
+ if (mxf->header_written)
+ return 1;
+
+ // Check for minimal frame size
+ if (pkt->size < 120000)
+ return -1;
+
+ vs_pack = pkt->data + 80*5 + 48;
+ vsc_pack = pkt->data + 80*5 + 53;
+ stype = vs_pack[3] & 0x1f;
+ pal = (vs_pack[3] >> 5) & 0x1;
+
+ if ((vs_pack[2] & 0x07) == 0x02)
+ sc->aspect_ratio = (AVRational){ 16, 9 };
+ else
+ sc->aspect_ratio = (AVRational){ 4, 3 };
+
+ sc->interlaced = (vsc_pack[3] >> 4) & 0x01;
+ // TODO: fix dv encoder to set proper FF/FS value in VSC pack
+ // and set field dominance accordingly
+ // av_log(s, AV_LOG_DEBUG, "DV vsc pack ff/ss = %x\n", vsc_pack[2] >> 6);
+
+ switch (stype) {
+ case 0x18: // DV100 720p
+ ul_index = 6 + pal;
+ frame_size = pal ? 288000 : 240000;
+ if (sc->interlaced) {
+ av_log(s, AV_LOG_ERROR, "source marked as interlaced but codec profile is progressive\n");
+ sc->interlaced = 0;
+ }
+ break;
+ case 0x14: // DV100 1080i
+ ul_index = 4 + pal;
+ frame_size = pal ? 576000 : 480000;
+ break;
+ case 0x04: // DV50
+ ul_index = 2 + pal;
+ frame_size = pal ? 288000 : 240000;
+ break;
+ default: // DV25
+ ul_index = 0 + pal;
+ frame_size = pal ? 144000 : 120000;
+ }
+
+ sc->index = ul_index + 16;
+ sc->codec_ul = &mxf_essence_container_uls[sc->index].codec_ul;
+
+ if(s->oformat == &ff_mxf_opatom_muxer) {
+ mxf->edit_unit_byte_count = frame_size;
+ return 1;
+ }
+
+ mxf->edit_unit_byte_count = KAG_SIZE;
+ for (i = 0; i < s->nb_streams; i++) {
+ AVStream *st = s->streams[i];
+ MXFStreamContext *sc = st->priv_data;
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+ mxf->edit_unit_byte_count += 16 + 4 + sc->aic.samples[0]*sc->aic.sample_size;
+ mxf->edit_unit_byte_count += klv_fill_size(mxf->edit_unit_byte_count);
+ } else if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+ mxf->edit_unit_byte_count += 16 + 4 + frame_size;
+ mxf->edit_unit_byte_count += klv_fill_size(mxf->edit_unit_byte_count);
+ }
+ }
+
+ return 1;
+}
+
+static const struct {
+ UID uid;
+ int frame_size;
+ int profile;
+ uint8_t interlaced;
+} mxf_h264_codec_uls[] = {
+ {{ 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0a,0x04,0x01,0x02,0x02,0x01,0x32,0x20,0x01 }, 0, 110, 0 }, // AVC High 10 Intra
+ {{ 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0a,0x04,0x01,0x02,0x02,0x01,0x32,0x21,0x01 }, 232960, 0, 1 }, // AVC Intra 50 1080i60
+ {{ 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0a,0x04,0x01,0x02,0x02,0x01,0x32,0x21,0x02 }, 281088, 0, 1 }, // AVC Intra 50 1080i50
+ {{ 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0a,0x04,0x01,0x02,0x02,0x01,0x32,0x21,0x03 }, 232960, 0, 0 }, // AVC Intra 50 1080p30
+ {{ 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0a,0x04,0x01,0x02,0x02,0x01,0x32,0x21,0x04 }, 281088, 0, 0 }, // AVC Intra 50 1080p25
+ {{ 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0a,0x04,0x01,0x02,0x02,0x01,0x32,0x21,0x08 }, 116736, 0, 0 }, // AVC Intra 50 720p60
+ {{ 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0a,0x04,0x01,0x02,0x02,0x01,0x32,0x21,0x09 }, 140800, 0, 0 }, // AVC Intra 50 720p50
+ {{ 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0a,0x04,0x01,0x02,0x02,0x01,0x32,0x30,0x01 }, 0, 122, 0 }, // AVC High 422 Intra
+ {{ 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0a,0x04,0x01,0x02,0x02,0x01,0x32,0x31,0x01 }, 472576, 0, 1 }, // AVC Intra 100 1080i60
+ {{ 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0a,0x04,0x01,0x02,0x02,0x01,0x32,0x31,0x02 }, 568832, 0, 1 }, // AVC Intra 100 1080i50
+ {{ 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0a,0x04,0x01,0x02,0x02,0x01,0x32,0x31,0x03 }, 472576, 0, 0 }, // AVC Intra 100 1080p30
+ {{ 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0a,0x04,0x01,0x02,0x02,0x01,0x32,0x31,0x04 }, 568832, 0, 0 }, // AVC Intra 100 1080p25
+ {{ 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0a,0x04,0x01,0x02,0x02,0x01,0x32,0x31,0x08 }, 236544, 0, 0 }, // AVC Intra 100 720p60
+ {{ 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0a,0x04,0x01,0x02,0x02,0x01,0x32,0x31,0x09 }, 284672, 0, 0 }, // AVC Intra 100 720p50
+};
+
+static int mxf_parse_h264_frame(AVFormatContext *s, AVStream *st,
+ AVPacket *pkt, MXFIndexEntry *e)
+{
+ MXFContext *mxf = s->priv_data;
+ MXFStreamContext *sc = st->priv_data;
+ static const int mxf_h264_num_codec_uls = sizeof(mxf_h264_codec_uls) / sizeof(mxf_h264_codec_uls[0]);
+ const uint8_t *buf = pkt->data;
+ const uint8_t *buf_end = pkt->data + pkt->size;
+ uint32_t state = -1;
+ int extra_size = 512; // support AVC Intra files without SPS/PPS header
+ int i, frame_size;
+ uint8_t uid_found;
+
+ if (pkt->size > extra_size)
+ buf_end -= pkt->size - extra_size; // no need to parse beyond SPS/PPS header
+
+ for (;;) {
+ buf = avpriv_find_start_code(buf, buf_end, &state);
+ if (buf >= buf_end)
+ break;
+ --buf;
+ switch (state & 0x1f) {
- case NAL_SPS:
++ case H264_NAL_SPS:
+ st->codecpar->profile = buf[1];
+ e->flags |= 0x40;
+ break;
- case NAL_PPS:
++ case H264_NAL_PPS:
+ if (e->flags & 0x40) { // sequence header present
+ e->flags |= 0x80; // random access
+ extra_size = 0;
+ buf = buf_end;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (mxf->header_written)
+ return 1;
+
+ sc->aspect_ratio = (AVRational){ 16, 9 }; // 16:9 is mandatory for broadcast HD
+ sc->component_depth = 10; // AVC Intra is always 10 Bit
+ sc->interlaced = st->codecpar->field_order != AV_FIELD_PROGRESSIVE ? 1 : 0;
+ if (sc->interlaced)
+ sc->field_dominance = 1; // top field first is mandatory for AVC Intra
+
+ uid_found = 0;
+ frame_size = pkt->size + extra_size;
+ for (i = 0; i < mxf_h264_num_codec_uls; i++) {
+ if (frame_size == mxf_h264_codec_uls[i].frame_size && sc->interlaced == mxf_h264_codec_uls[i].interlaced) {
+ sc->codec_ul = &mxf_h264_codec_uls[i].uid;
+ return 1;
+ } else if (st->codecpar->profile == mxf_h264_codec_uls[i].profile) {
+ sc->codec_ul = &mxf_h264_codec_uls[i].uid;
+ uid_found = 1;
+ }
+ }
+
+ if (!uid_found) {
+ av_log(s, AV_LOG_ERROR, "AVC Intra 50/100 supported only\n");
+ return 0;
+ }
+
+ return 1;
+}
+
static const UID mxf_mpeg2_codec_uls[] = {
{ 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x03,0x04,0x01,0x02,0x02,0x01,0x01,0x10,0x00 }, // MP-ML I-Frame
{ 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x03,0x04,0x01,0x02,0x02,0x01,0x01,0x11,0x00 }, // MP-ML Long GOP
1
0
ffmpeg | branch: master | Anton Khirnov <anton(a)khirnov.net> | Wed May 18 10:36:33 2016 +0200| [5c2fb561d94fc51d76ab21d6f7cc5b6cc3aa599c] | committer: Anton Khirnov
h264: add H264_ prefix to the NAL unit types
This will prevent conflicts e.g. in code that deals with both h264 and
hevc.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5c2fb561d94fc51d7…
---
libavcodec/h264.h | 28 +++++++++++------------
libavcodec/h264_parse.c | 4 ++--
libavcodec/h264_parser.c | 28 +++++++++++------------
libavcodec/h264_refs.c | 2 +-
libavcodec/h264_slice.c | 6 ++---
libavcodec/h264dec.c | 50 +++++++++++++++++++++---------------------
libavcodec/omx.c | 2 +-
libavcodec/vaapi_encode_h264.c | 10 ++++-----
8 files changed, 65 insertions(+), 65 deletions(-)
diff --git a/libavcodec/h264.h b/libavcodec/h264.h
index 6a9b496..eb3805c 100644
--- a/libavcodec/h264.h
+++ b/libavcodec/h264.h
@@ -28,20 +28,20 @@
/* NAL unit types */
enum {
- NAL_SLICE = 1,
- NAL_DPA = 2,
- NAL_DPB = 3,
- NAL_DPC = 4,
- NAL_IDR_SLICE = 5,
- NAL_SEI = 6,
- NAL_SPS = 7,
- NAL_PPS = 8,
- NAL_AUD = 9,
- NAL_END_SEQUENCE = 10,
- NAL_END_STREAM = 11,
- NAL_FILLER_DATA = 12,
- NAL_SPS_EXT = 13,
- NAL_AUXILIARY_SLICE = 19,
+ H264_NAL_SLICE = 1,
+ H264_NAL_DPA = 2,
+ H264_NAL_DPB = 3,
+ H264_NAL_DPC = 4,
+ H264_NAL_IDR_SLICE = 5,
+ H264_NAL_SEI = 6,
+ H264_NAL_SPS = 7,
+ H264_NAL_PPS = 8,
+ H264_NAL_AUD = 9,
+ H264_NAL_END_SEQUENCE = 10,
+ H264_NAL_END_STREAM = 11,
+ H264_NAL_FILLER_DATA = 12,
+ H264_NAL_SPS_EXT = 13,
+ H264_NAL_AUXILIARY_SLICE = 19,
};
#endif /* AVCODEC_H264_H */
diff --git a/libavcodec/h264_parse.c b/libavcodec/h264_parse.c
index 0aa6f09..d694558 100644
--- a/libavcodec/h264_parse.c
+++ b/libavcodec/h264_parse.c
@@ -330,12 +330,12 @@ static int decode_extradata_ps(const uint8_t *data, int size, H264ParamSets *ps,
for (i = 0; i < pkt.nb_nals; i++) {
H2645NAL *nal = &pkt.nals[i];
switch (nal->type) {
- case NAL_SPS:
+ case H264_NAL_SPS:
ret = ff_h264_decode_seq_parameter_set(&nal->gb, logctx, ps);
if (ret < 0)
goto fail;
break;
- case NAL_PPS:
+ case H264_NAL_PPS:
ret = ff_h264_decode_picture_parameter_set(&nal->gb, logctx, ps,
nal->size_bits);
if (ret < 0)
diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c
index 00db1d8..b4da123 100644
--- a/libavcodec/h264_parser.c
+++ b/libavcodec/h264_parser.c
@@ -83,14 +83,14 @@ static int h264_find_frame_end(H264ParseContext *p, const uint8_t *buf,
state >>= 1; // 2->1, 1->0, 0->0
} else if (state <= 5) {
int nalu_type = buf[i] & 0x1F;
- if (nalu_type == NAL_SEI || nalu_type == NAL_SPS ||
- nalu_type == NAL_PPS || nalu_type == NAL_AUD) {
+ if (nalu_type == H264_NAL_SEI || nalu_type == H264_NAL_SPS ||
+ nalu_type == H264_NAL_PPS || nalu_type == H264_NAL_AUD) {
if (pc->frame_start_found) {
i++;
goto found;
}
- } else if (nalu_type == NAL_SLICE || nalu_type == NAL_DPA ||
- nalu_type == NAL_IDR_SLICE) {
+ } else if (nalu_type == H264_NAL_SLICE || nalu_type == H264_NAL_DPA ||
+ nalu_type == H264_NAL_IDR_SLICE) {
if (pc->frame_start_found) {
state += 8;
continue;
@@ -234,10 +234,10 @@ static inline int parse_nal_units(AVCodecParserContext *s,
--buf;
src_length = buf_end - buf;
switch (state & 0x1f) {
- case NAL_SLICE:
- case NAL_IDR_SLICE:
+ case H264_NAL_SLICE:
+ case H264_NAL_IDR_SLICE:
// Do not walk the whole buffer just to decode slice header
- if ((state & 0x1f) == NAL_IDR_SLICE || ((state >> 5) & 0x3) == 0) {
+ if ((state & 0x1f) == H264_NAL_IDR_SLICE || ((state >> 5) & 0x3) == 0) {
/* IDR or disposable slice
* No need to decode many bytes because MMCOs shall not be present. */
if (src_length > 60)
@@ -262,17 +262,17 @@ static inline int parse_nal_units(AVCodecParserContext *s,
nal.type = get_bits(&nal.gb, 5);
switch (nal.type) {
- case NAL_SPS:
+ case H264_NAL_SPS:
ff_h264_decode_seq_parameter_set(&nal.gb, avctx, &p->ps);
break;
- case NAL_PPS:
+ case H264_NAL_PPS:
ff_h264_decode_picture_parameter_set(&nal.gb, avctx, &p->ps,
nal.size_bits);
break;
- case NAL_SEI:
+ case H264_NAL_SEI:
ff_h264_sei_decode(&p->sei, &nal.gb, &p->ps, avctx);
break;
- case NAL_IDR_SLICE:
+ case H264_NAL_IDR_SLICE:
s->key_frame = 1;
p->poc.prev_frame_num = 0;
@@ -280,7 +280,7 @@ static inline int parse_nal_units(AVCodecParserContext *s,
p->poc.prev_poc_msb =
p->poc.prev_poc_lsb = 0;
/* fall through */
- case NAL_SLICE:
+ case H264_NAL_SLICE:
get_ue_golomb(&nal.gb); // skip first_mb_in_slice
slice_type = get_ue_golomb_31(&nal.gb);
s->pict_type = ff_h264_golomb_to_pict_type[slice_type % 5];
@@ -353,7 +353,7 @@ static inline int parse_nal_units(AVCodecParserContext *s,
}
}
- if (nal.type == NAL_IDR_SLICE)
+ if (nal.type == H264_NAL_IDR_SLICE)
get_ue_golomb(&nal.gb); /* idr_pic_id */
if (sps->poc_type == 0) {
p->poc.poc_lsb = get_bits(&nal.gb, sps->log2_max_poc_lsb);
@@ -382,7 +382,7 @@ static inline int parse_nal_units(AVCodecParserContext *s,
* FIXME: MMCO_RESET could appear in non-first slice.
* Maybe, we should parse all undisposable non-IDR slice of this
* picture until encountering MMCO_RESET in a slice of it. */
- if (nal.ref_idc && nal.type != NAL_IDR_SLICE) {
+ if (nal.ref_idc && nal.type != H264_NAL_IDR_SLICE) {
got_reset = scan_mmco_reset(s, &nal.gb, avctx);
if (got_reset < 0)
goto fail;
diff --git a/libavcodec/h264_refs.c b/libavcodec/h264_refs.c
index 4172fbd..2077847 100644
--- a/libavcodec/h264_refs.c
+++ b/libavcodec/h264_refs.c
@@ -735,7 +735,7 @@ int ff_h264_decode_ref_pic_marking(const H264Context *h, H264SliceContext *sl,
MMCO *mmco = sl->mmco;
int nb_mmco = 0;
- if (h->nal_unit_type == NAL_IDR_SLICE) { // FIXME fields
+ if (h->nal_unit_type == H264_NAL_IDR_SLICE) { // FIXME fields
skip_bits1(gb); // broken_link
if (get_bits1(gb)) {
mmco[0].opcode = MMCO_LONG;
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index f07f37e..376be27 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -1374,7 +1374,7 @@ static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl,
sl->slice_type = slice_type;
sl->slice_type_nos = slice_type & 3;
- if (nal->type == NAL_IDR_SLICE &&
+ if (nal->type == H264_NAL_IDR_SLICE &&
sl->slice_type_nos != AV_PICTURE_TYPE_I) {
av_log(h->avctx, AV_LOG_ERROR, "A non-intra slice in an IDR NAL unit.\n");
return AVERROR_INVALIDDATA;
@@ -1427,7 +1427,7 @@ static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl,
sl->max_pic_num = 1 << (sps->log2_max_frame_num + 1);
}
- if (nal->type == NAL_IDR_SLICE)
+ if (nal->type == H264_NAL_IDR_SLICE)
get_ue_golomb(&sl->gb); /* idr_pic_id */
if (sps->poc_type == 0) {
@@ -1701,7 +1701,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl,
sl->mb_y * h->mb_width + sl->mb_x,
av_get_picture_type_char(sl->slice_type),
sl->slice_type_fixed ? " fix" : "",
- nal->type == NAL_IDR_SLICE ? " IDR" : "",
+ nal->type == H264_NAL_IDR_SLICE ? " IDR" : "",
h->poc.frame_num,
h->cur_pic_ptr->field_poc[0],
h->cur_pic_ptr->field_poc[1],
diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index b4b78bd..52cb9ae 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -639,13 +639,13 @@ static int get_last_needed_nal(H264Context *h)
* which splits NALs strangely if so, when frame threading we
* can't start the next thread until we've read all of them */
switch (nal->type) {
- case NAL_SPS:
- case NAL_PPS:
+ case H264_NAL_SPS:
+ case H264_NAL_PPS:
nals_needed = i;
break;
- case NAL_DPA:
- case NAL_IDR_SLICE:
- case NAL_SLICE:
+ case H264_NAL_DPA:
+ case H264_NAL_IDR_SLICE:
+ case H264_NAL_SLICE:
init_get_bits(&gb, nal->data + 1, (nal->size - 1) * 8);
if (!get_ue_golomb(&gb))
nals_needed = i;
@@ -686,7 +686,7 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size)
int err;
if (avctx->skip_frame >= AVDISCARD_NONREF &&
- nal->ref_idc == 0 && nal->type != NAL_SEI)
+ nal->ref_idc == 0 && nal->type != H264_NAL_SEI)
continue;
// FIXME these should stop being context-global variables
@@ -695,15 +695,15 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size)
err = 0;
switch (nal->type) {
- case NAL_IDR_SLICE:
- if (nal->type != NAL_IDR_SLICE) {
+ case H264_NAL_IDR_SLICE:
+ if (nal->type != H264_NAL_IDR_SLICE) {
av_log(h->avctx, AV_LOG_ERROR,
"Invalid mix of idr and non-idr slices\n");
ret = -1;
goto end;
}
idr(h); // FIXME ensure we don't lose some frames if there is reordering
- case NAL_SLICE:
+ case H264_NAL_SLICE:
sl->gb = nal->gb;
if ((err = ff_h264_decode_slice_header(h, sl, nal)))
@@ -715,15 +715,15 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size)
}
h->cur_pic_ptr->f->key_frame |=
- (nal->type == NAL_IDR_SLICE) || (h->sei.recovery_point.recovery_frame_cnt >= 0);
+ (nal->type == H264_NAL_IDR_SLICE) || (h->sei.recovery_point.recovery_frame_cnt >= 0);
- if (nal->type == NAL_IDR_SLICE || h->recovery_frame == h->poc.frame_num) {
+ if (nal->type == H264_NAL_IDR_SLICE || h->recovery_frame == h->poc.frame_num) {
h->recovery_frame = -1;
h->cur_pic_ptr->recovered = 1;
}
// If we have an IDR, all frames after it in decoded order are
// "recovered".
- if (nal->type == NAL_IDR_SLICE)
+ if (nal->type == H264_NAL_IDR_SLICE)
h->frame_recovered |= FRAME_RECOVERED_IDR;
h->cur_pic_ptr->recovered |= !!(h->frame_recovered & FRAME_RECOVERED_IDR);
@@ -751,35 +751,35 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size)
context_count++;
}
break;
- case NAL_DPA:
- case NAL_DPB:
- case NAL_DPC:
+ case H264_NAL_DPA:
+ case H264_NAL_DPB:
+ case H264_NAL_DPC:
avpriv_request_sample(avctx, "data partitioning");
ret = AVERROR(ENOSYS);
goto end;
break;
- case NAL_SEI:
+ case H264_NAL_SEI:
ret = ff_h264_sei_decode(&h->sei, &nal->gb, &h->ps, avctx);
if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
goto end;
break;
- case NAL_SPS:
+ case H264_NAL_SPS:
ret = ff_h264_decode_seq_parameter_set(&nal->gb, avctx, &h->ps);
if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
goto end;
break;
- case NAL_PPS:
+ case H264_NAL_PPS:
ret = ff_h264_decode_picture_parameter_set(&nal->gb, avctx, &h->ps,
nal->size_bits);
if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
goto end;
break;
- case NAL_AUD:
- case NAL_END_SEQUENCE:
- case NAL_END_STREAM:
- case NAL_FILLER_DATA:
- case NAL_SPS_EXT:
- case NAL_AUXILIARY_SLICE:
+ case H264_NAL_AUD:
+ case H264_NAL_END_SEQUENCE:
+ case H264_NAL_END_STREAM:
+ case H264_NAL_FILLER_DATA:
+ case H264_NAL_SPS_EXT:
+ case H264_NAL_AUXILIARY_SLICE:
break;
default:
av_log(avctx, AV_LOG_DEBUG, "Unknown NAL code: %d (%d bits)\n",
@@ -912,7 +912,7 @@ out:
if (buf_index < 0)
return AVERROR_INVALIDDATA;
- if (!h->cur_pic_ptr && h->nal_unit_type == NAL_END_SEQUENCE) {
+ if (!h->cur_pic_ptr && h->nal_unit_type == H264_NAL_END_SEQUENCE) {
buf_size = 0;
goto out;
}
diff --git a/libavcodec/omx.c b/libavcodec/omx.c
index 961ff86..63c7f5b 100644
--- a/libavcodec/omx.c
+++ b/libavcodec/omx.c
@@ -703,7 +703,7 @@ static av_cold int omx_encode_init(AVCodecContext *avctx)
nals[avctx->extradata[i + 4] & 0x1f]++;
}
}
- if (nals[NAL_SPS] && nals[NAL_PPS])
+ if (nals[H264_NAL_SPS] && nals[H264_NAL_PPS])
break;
} else {
if (avctx->extradata_size > 0)
diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
index a288980..5bd5605 100644
--- a/libavcodec/vaapi_encode_h264.c
+++ b/libavcodec/vaapi_encode_h264.c
@@ -283,7 +283,7 @@ static void vaapi_encode_h264_write_sps(PutBitContext *pbc,
VAAPIEncodeH264MiscSequenceParams *mseq = &priv->misc_sequence_params;
int i;
- vaapi_encode_h264_write_nal_header(pbc, NAL_SPS, 3);
+ vaapi_encode_h264_write_nal_header(pbc, H264_NAL_SPS, 3);
u(8, mseq_var(profile_idc));
u(1, mseq_var(constraint_set0_flag));
@@ -368,7 +368,7 @@ static void vaapi_encode_h264_write_pps(PutBitContext *pbc,
VAAPIEncodeH264Context *priv = ctx->priv_data;
VAAPIEncodeH264MiscSequenceParams *mseq = &priv->misc_sequence_params;
- vaapi_encode_h264_write_nal_header(pbc, NAL_PPS, 3);
+ vaapi_encode_h264_write_nal_header(pbc, H264_NAL_PPS, 3);
ue(vpic_var(pic_parameter_set_id));
ue(vpic_var(seq_parameter_set_id));
@@ -642,7 +642,7 @@ static void vaapi_encode_h264_write_sei(PutBitContext *pbc,
VAAPIEncodeContext *ctx,
VAAPIEncodePicture *pic) = NULL;
- vaapi_encode_h264_write_nal_header(pbc, NAL_SEI, 0);
+ vaapi_encode_h264_write_nal_header(pbc, H264_NAL_SEI, 0);
for (payload_type = 0; payload_type < 64; payload_type++) {
switch (payload_type) {
@@ -1010,9 +1010,9 @@ static int vaapi_encode_h264_init_slice_params(AVCodecContext *avctx,
mslice = &pslice->misc_slice_params;
if (pic->type == PICTURE_TYPE_IDR)
- mslice->nal_unit_type = NAL_IDR_SLICE;
+ mslice->nal_unit_type = H264_NAL_IDR_SLICE;
else
- mslice->nal_unit_type = NAL_SLICE;
+ mslice->nal_unit_type = H264_NAL_SLICE;
switch (pic->type) {
case PICTURE_TYPE_IDR:
1
0
ffmpeg | branch: master | Burt P <pburt0(a)gmail.com> | Fri Jul 29 12:36:20 2016 -0500| [12759cc0345cec5a418d8caec5435297d1ec04b2] | committer: Michael Niedermayer
af_hdcd: Move code detect/check into own function
Signed-off-by: Burt P <pburt0(a)gmail.com>
Signed-off-by: Michael Niedermayer <michael(a)niedermayer.cc>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=12759cc0345cec5a4…
---
libavfilter/af_hdcd.c | 86 +++++++++++++++++++++++++++++++++++----------------
1 file changed, 60 insertions(+), 26 deletions(-)
diff --git a/libavfilter/af_hdcd.c b/libavfilter/af_hdcd.c
index 8e27d8a..0752c39 100644
--- a/libavfilter/af_hdcd.c
+++ b/libavfilter/af_hdcd.c
@@ -933,6 +933,45 @@ static void hdcd_update_info(hdcd_state_t *state)
state->max_gain = FFMAX(state->max_gain, (state->control & 15));
}
+typedef enum {
+ HDCD_CODE_NONE=0,
+ HDCD_CODE_A,
+ HDCD_CODE_A_ALMOST,
+ HDCD_CODE_B,
+ HDCD_CODE_B_CHECKFAIL,
+ HDCD_CODE_EXPECT_A,
+ HDCD_CODE_EXPECT_B,
+} hdcd_code_result_t;
+
+static hdcd_code_result_t hdcd_code(const uint32_t bits, unsigned char *code)
+{
+ if ((bits & 0x0fa00500) == 0x0fa00500) {
+ /* A: 8-bit code 0x7e0fa005[..] */
+ if ((bits & 0xc8) == 0) {
+ /* [..pt gggg]
+ * 0x0fa005[..] -> 0b[00.. 0...], gain part doubled */
+ *code = (bits & 255) + (bits & 7);
+ return HDCD_CODE_A;
+ } else
+ return HDCD_CODE_A_ALMOST; /* one of bits 3, 6, or 7 was not 0 */
+ } else if ((bits & 0xa0060000) == 0xa0060000) {
+ /* B: 8-bit code, 8-bit XOR check, 0x7e0fa006[....] */
+ if (((bits ^ (~bits >> 8 & 255)) & 0xffff00ff) == 0xa0060000) {
+ /* check: [..pt gggg ~(..pt gggg)]
+ * 0xa006[....] -> 0b[.... .... .... .... ] */
+ *code = bits >> 8 & 255;
+ return HDCD_CODE_B;
+ } else
+ return HDCD_CODE_B_CHECKFAIL; /* XOR check failed */
+ }
+ if (bits == 0x7e0fa005)
+ return HDCD_CODE_EXPECT_A;
+ else if (bits == 0x7e0fa006)
+ return HDCD_CODE_EXPECT_B;
+
+ return HDCD_CODE_NONE;
+}
+
static int hdcd_integrate(HDCDContext *ctx, hdcd_state_t *state, int *flag, const int32_t *samples, int count, int stride)
{
uint32_t bits = 0;
@@ -953,44 +992,39 @@ static int hdcd_integrate(HDCDContext *ctx, hdcd_state_t *state, int *flag, cons
bits = (state->window ^ state->window >> 5 ^ state->window >> 23);
if (state->arg) {
- if ((bits & 0x0fa00500) == 0x0fa00500) {
- /* A: 8-bit code */
- if ((bits & 0xc8) == 0) {
- /* [..pt gggg]
- * 0x0fa005[..] -> 0b[00.. 0...], gain part doubled */
- state->control = (bits & 255) + (bits & 7);
+ switch (hdcd_code(bits, &state->control)) {
+ case HDCD_CODE_A:
*flag = 1;
state->code_counterA++;
- } else {
- /* one of bits 3, 6, or 7 was not 0 */
+ break;
+ case HDCD_CODE_B:
+ *flag = 1;
+ state->code_counterB++;
+ break;
+ case HDCD_CODE_A_ALMOST:
state->code_counterA_almost++;
av_log(ctx->fctx, AV_LOG_VERBOSE,
"hdcd error: Control A almost: 0x%02x near %d\n", bits & 0xff, ctx->sample_count);
- }
- } else if ((bits & 0xa0060000) == 0xa0060000) {
- /* B: 8-bit code, 8-bit XOR check */
- if (((bits ^ (~bits >> 8 & 255)) & 0xffff00ff) == 0xa0060000) {
- /* check: [..pt gggg ~(..pt gggg)]
- * 0xa006[....] -> 0b[.... .... .... .... ] */
- state->control = bits >> 8 & 255;
- *flag = 1;
- state->code_counterB++;
- } else {
- /* XOR check failed */
+ break;
+ case HDCD_CODE_B_CHECKFAIL:
state->code_counterB_checkfails++;
av_log(ctx->fctx, AV_LOG_VERBOSE,
- "hdcd error: Control B check failed: 0x%04x (0x%02x vs 0x%02x) near %d\n", bits & 0xffff, (bits & 0xff00) >> 8, ~bits & 0xff, ctx->sample_count);
- }
- } else {
- /* told to look for a code, but didn't match one */
- state->code_counterC_unmatched++;
- av_log(ctx->fctx, AV_LOG_VERBOSE,
- "hdcd error: Unmatched code: 0x%08x near %d\n", bits, ctx->sample_count);
+ "hdcd error: Control B check failed: 0x%04x (0x%02x vs 0x%02x) near %d\n", bits & 0xffff, (bits & 0xff00) >> 8, ~bits & 0xff, ctx->sample_count);
+ break;
+ case HDCD_CODE_NONE:
+ state->code_counterC_unmatched++;
+ av_log(ctx->fctx, AV_LOG_VERBOSE,
+ "hdcd error: Unmatched code: 0x%08x near %d\n", bits, ctx->sample_count);
+ default:
+ av_log(ctx->fctx, AV_LOG_INFO,
+ "hdcd error: Unexpected return value from hdcd_code()\n");
+ av_assert0(0); /* die */
}
if (*flag) hdcd_update_info(state);
state->arg = 0;
}
if (bits == 0x7e0fa005 || bits == 0x7e0fa006) {
+ /* 0x7e0fa00[.]-> [0b0101 or 0b0110] */
state->readahead = (bits & 3) * 8;
state->arg = 1;
state->code_counterC++;
1
0