aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/ffv1enc.c
diff options
context:
space:
mode:
authorVittorio Giovara <vittorio.giovara@gmail.com>2015-09-13 23:45:24 +0200
committerVittorio Giovara <vittorio.giovara@gmail.com>2016-01-21 15:33:19 -0500
commit96c373c7704aeb1cc1d2c275fbb5d71777665589 (patch)
treeb2a0a23150ac3a4126925bbcc9d12d27f46f8931 /libavcodec/ffv1enc.c
parent12b49769223234673db1003d9c43e7483ceb0282 (diff)
downloadffmpeg-96c373c7704aeb1cc1d2c275fbb5d71777665589.tar.gz
lavc: Move context_model to codec private options
This option is only used by ffv1 and ffvhuff. It is a very codec-specific option, so deprecate the global variant. Improve documentation a little. Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
Diffstat (limited to 'libavcodec/ffv1enc.c')
-rw-r--r--libavcodec/ffv1enc.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
index 061e90829f..9c2e463e6c 100644
--- a/libavcodec/ffv1enc.c
+++ b/libavcodec/ffv1enc.c
@@ -261,7 +261,7 @@ static void encode_plane(FFV1Context *s, uint8_t *src, int w, int h,
int stride, int plane_index)
{
int x, y, i;
- const int ring_size = s->avctx->context_model ? 3 : 2;
+ const int ring_size = s->context_model ? 3 : 2;
int16_t *sample[3];
s->run_index = 0;
@@ -297,7 +297,7 @@ static void encode_rgb_frame(FFV1Context *s, const uint8_t *src[3],
int w, int h, const int stride[3])
{
int x, y, p, i;
- const int ring_size = s->avctx->context_model ? 3 : 2;
+ const int ring_size = s->context_model ? 3 : 2;
int16_t *sample[MAX_PLANES][3];
int lbd = s->avctx->bits_per_raw_sample <= 8;
int bits = s->avctx->bits_per_raw_sample > 0
@@ -418,7 +418,7 @@ static void write_header(FFV1Context *f)
0);
for (j = 0; j < f->plane_count; j++) {
put_symbol(c, state, f->plane[j].quant_table_index, 0);
- av_assert0(f->plane[j].quant_table_index == f->avctx->context_model);
+ av_assert0(f->plane[j].quant_table_index == f->context_model);
}
}
}
@@ -671,12 +671,18 @@ FF_ENABLE_DEPRECATION_WARNINGS
avctx, AV_LOG_WARNING,
"Storing alpha plane, this will require a recent FFV1 decoder to playback!\n");
}
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (avctx->context_model)
+ s->context_model = avctx->context_model;
if (avctx->context_model > 1U) {
av_log(avctx, AV_LOG_ERROR,
"Invalid context model %d, valid values are 0 and 1\n",
avctx->context_model);
return AVERROR(EINVAL);
}
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
if (s->ac == AC_RANGE_CUSTOM_TAB)
for (i = 1; i < 256; i++)
@@ -706,14 +712,14 @@ FF_ENABLE_DEPRECATION_WARNINGS
}
s->context_count[0] = (11 * 11 * 11 + 1) / 2;
s->context_count[1] = (11 * 11 * 5 * 5 * 5 + 1) / 2;
- memcpy(s->quant_table, s->quant_tables[avctx->context_model],
+ memcpy(s->quant_table, s->quant_tables[s->context_model],
sizeof(s->quant_table));
for (i = 0; i < s->plane_count; i++) {
PlaneContext *const p = &s->plane[i];
memcpy(p->quant_table, s->quant_table, sizeof(p->quant_table));
- p->quant_table_index = avctx->context_model;
+ p->quant_table_index = s->context_model;
p->context_count = s->context_count[p->quant_table_index];
}
@@ -860,7 +866,7 @@ static void encode_slice_header(FFV1Context *f, FFV1Context *fs)
0);
for (j = 0; j < f->plane_count; j++) {
put_symbol(c, state, f->plane[j].quant_table_index, 0);
- av_assert0(f->plane[j].quant_table_index == f->avctx->context_model);
+ av_assert0(f->plane[j].quant_table_index == f->context_model);
}
if (!f->frame->interlaced_frame)
put_symbol(c, state, 3, 0);
@@ -1081,6 +1087,8 @@ static const AVOption options[] = {
{ .i64 = AC_RANGE_DEFAULT_TAB }, INT_MIN, INT_MAX, VE, "coder" },
{ "range_tab", "Range with custom table", 0, AV_OPT_TYPE_CONST,
{ .i64 = AC_RANGE_CUSTOM_TAB }, INT_MIN, INT_MAX, VE, "coder" },
+ { "context", "Context model", OFFSET(context_model), AV_OPT_TYPE_INT,
+ { .i64 = 0 }, 0, 1, VE },
{ NULL }
};