--- libavcodec/ffv1.h | 3 ++- libavcodec/ffv1enc.c | 7 ++++--- libavcodec/ffv1enc_template.c | 14 +++++++------- 3 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h index c88aa8c30d..dce6e177eb 100644 --- a/libavcodec/ffv1.h +++ b/libavcodec/ffv1.h @@ -79,13 +79,14 @@ typedef struct FFV1SliceContext { int slice_y; int run_index; + + PutBitContext pb; } FFV1SliceContext; typedef struct FFV1Context { AVClass *class; AVCodecContext *avctx; RangeCoder c; - PutBitContext pb; uint64_t rc_stat[256][2]; uint64_t (*rc_stat2[MAX_QUANT_TABLES])[32][2]; int version; diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c index 8bb9174a1d..5692bfa1fc 100644 --- a/libavcodec/ffv1enc.c +++ b/libavcodec/ffv1enc.c @@ -1057,7 +1057,7 @@ retry: } if (fs->ac == AC_GOLOMB_RICE) { fs->ac_byte_count = f->version > 2 || (!x && !y) ? ff_rac_terminate(&fs->c, f->version > 2) : 0; - init_put_bits(&fs->pb, + init_put_bits(&sc->pb, fs->c.bytestream_start + fs->ac_byte_count, fs->c.bytestream_end - fs->c.bytestream_start - fs->ac_byte_count); } @@ -1209,13 +1209,14 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, buf_p = pkt->data; for (i = 0; i < f->slice_count; i++) { FFV1Context *fs = f->slice_context[i]; + FFV1SliceContext *sc = &f->slices[i]; int bytes; if (fs->ac != AC_GOLOMB_RICE) { bytes = ff_rac_terminate(&fs->c, 1); } else { - flush_put_bits(&fs->pb); // FIXME: nicer padding - bytes = fs->ac_byte_count + put_bytes_output(&fs->pb); + flush_put_bits(&sc->pb); // FIXME: nicer padding + bytes = fs->ac_byte_count + put_bytes_output(&sc->pb); } if (i > 0 || f->version > 2) { av_assert0(bytes < pkt->size / f->slice_count); diff --git a/libavcodec/ffv1enc_template.c b/libavcodec/ffv1enc_template.c index 4dccd531a8..8b9e53fa1b 100644 --- a/libavcodec/ffv1enc_template.c +++ b/libavcodec/ffv1enc_template.c @@ -39,7 +39,7 @@ RENAME(encode_line)(FFV1Context *s, FFV1SliceContext *sc, return AVERROR_INVALIDDATA; } } else { - if (put_bytes_left(&s->pb, 0) < w * 4) { + if (put_bytes_left(&sc->pb, 0) < w * 4) { av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n"); return AVERROR_INVALIDDATA; } @@ -86,10 +86,10 @@ RENAME(encode_line)(FFV1Context *s, FFV1SliceContext *sc, while (run_count >= 1 << ff_log2_run[run_index]) { run_count -= 1 << ff_log2_run[run_index]; run_index++; - put_bits(&s->pb, 1, 1); + put_bits(&sc->pb, 1, 1); } - put_bits(&s->pb, 1 + ff_log2_run[run_index], run_count); + put_bits(&sc->pb, 1 + ff_log2_run[run_index], run_count); if (run_index) run_index--; run_count = 0; @@ -103,21 +103,21 @@ RENAME(encode_line)(FFV1Context *s, FFV1SliceContext *sc, ff_dlog(s->avctx, "count:%d index:%d, mode:%d, x:%d pos:%d\n", run_count, run_index, run_mode, x, - (int)put_bits_count(&s->pb)); + (int)put_bits_count(&sc->pb)); if (run_mode == 0) - put_vlc_symbol(&s->pb, &p->vlc_state[context], diff, bits); + put_vlc_symbol(&sc->pb, &p->vlc_state[context], diff, bits); } } if (run_mode) { while (run_count >= 1 << ff_log2_run[run_index]) { run_count -= 1 << ff_log2_run[run_index]; run_index++; - put_bits(&s->pb, 1, 1); + put_bits(&sc->pb, 1, 1); } if (run_count) - put_bits(&s->pb, 1, 1); + put_bits(&sc->pb, 1, 1); } sc->run_index = run_index; -- 2.43.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".