mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-11-26 19:01:44 +02:00
lavc/ffv1enc: store per-slice rc_stat(2?) in FFV1SliceContext
Instead of the per-slice FFV1Context, which will be removed in future commits.
This commit is contained in:
parent
7b2bfba55d
commit
e7d0f44138
@ -127,7 +127,6 @@ av_cold int ff_ffv1_init_slice_contexts(FFV1Context *f)
|
||||
|
||||
f->slice_context[i++] = fs;
|
||||
memcpy(fs, f, sizeof(*fs));
|
||||
memset(fs->rc_stat2, 0, sizeof(fs->rc_stat2));
|
||||
|
||||
sc->slice_width = sxe - sxs;
|
||||
sc->slice_height = sye - sys;
|
||||
@ -208,9 +207,8 @@ av_cold int ff_ffv1_close(AVCodecContext *avctx)
|
||||
for (j = 0; j < s->quant_table_count; j++) {
|
||||
av_freep(&s->initial_states[j]);
|
||||
for (i = 0; i < s->max_slice_count; i++) {
|
||||
FFV1Context *sf = s->slice_context[i];
|
||||
if (sf)
|
||||
av_freep(&sf->rc_stat2[j]);
|
||||
FFV1SliceContext *sc = &s->slices[i];
|
||||
av_freep(&sc->rc_stat2[j]);
|
||||
}
|
||||
av_freep(&s->rc_stat2[j]);
|
||||
}
|
||||
|
@ -84,6 +84,9 @@ typedef struct FFV1SliceContext {
|
||||
PlaneContext plane[MAX_PLANES];
|
||||
PutBitContext pb;
|
||||
RangeCoder c;
|
||||
|
||||
uint64_t rc_stat[256][2];
|
||||
uint64_t (*rc_stat2[MAX_QUANT_TABLES])[32][2];
|
||||
} FFV1SliceContext;
|
||||
|
||||
typedef struct FFV1Context {
|
||||
|
@ -897,11 +897,11 @@ slices_ok:
|
||||
return AVERROR(ENOMEM);
|
||||
for (i = 0; i < s->quant_table_count; i++)
|
||||
for (j = 0; j < s->max_slice_count; j++) {
|
||||
FFV1Context *sf = s->slice_context[j];
|
||||
av_assert0(!sf->rc_stat2[i]);
|
||||
sf->rc_stat2[i] = av_mallocz(s->context_count[i] *
|
||||
sizeof(*sf->rc_stat2[i]));
|
||||
if (!sf->rc_stat2[i])
|
||||
FFV1SliceContext *sc = &s->slices[j];
|
||||
av_assert0(!sc->rc_stat2[i]);
|
||||
sc->rc_stat2[i] = av_mallocz(s->context_count[i] *
|
||||
sizeof(*sc->rc_stat2[i]));
|
||||
if (!sc->rc_stat2[i])
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
}
|
||||
@ -1127,16 +1127,16 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
||||
|
||||
av_assert0(f->slice_count == f->max_slice_count);
|
||||
for (j = 0; j < f->slice_count; j++) {
|
||||
FFV1Context *fs = f->slice_context[j];
|
||||
const FFV1SliceContext *sc = &f->slices[j];
|
||||
for (i = 0; i < 256; i++) {
|
||||
f->rc_stat[i][0] += fs->rc_stat[i][0];
|
||||
f->rc_stat[i][1] += fs->rc_stat[i][1];
|
||||
f->rc_stat[i][0] += sc->rc_stat[i][0];
|
||||
f->rc_stat[i][1] += sc->rc_stat[i][1];
|
||||
}
|
||||
for (i = 0; i < f->quant_table_count; i++) {
|
||||
for (k = 0; k < f->context_count[i]; k++)
|
||||
for (m = 0; m < 32; m++) {
|
||||
f->rc_stat2[i][k][m][0] += fs->rc_stat2[i][k][m][0];
|
||||
f->rc_stat2[i][k][m][1] += fs->rc_stat2[i][k][m][1];
|
||||
f->rc_stat2[i][k][m][0] += sc->rc_stat2[i][k][m][0];
|
||||
f->rc_stat2[i][k][m][1] += sc->rc_stat2[i][k][m][1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -75,8 +75,8 @@ RENAME(encode_line)(FFV1Context *f,
|
||||
|
||||
if (ac != AC_GOLOMB_RICE) {
|
||||
if (s->flags & AV_CODEC_FLAG_PASS1) {
|
||||
put_symbol_inline(c, p->state[context], diff, 1, s->rc_stat,
|
||||
s->rc_stat2[p->quant_table_index][context]);
|
||||
put_symbol_inline(c, p->state[context], diff, 1, sc->rc_stat,
|
||||
sc->rc_stat2[p->quant_table_index][context]);
|
||||
} else {
|
||||
put_symbol_inline(c, p->state[context], diff, 1, NULL, NULL);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user