[FFmpeg-cvslog] tests/fate/vcodec: add vsynth tests for FFV1 version 2
ffmpeg | branch: master | Anton Khirnov | Tue Jul 16 13:46:33 2024 +0200| [8e19c24634a0a442586b4c543da33d2843a1baa3] | committer: Anton Khirnov tests/fate/vcodec: add vsynth tests for FFV1 version 2 > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8e19c24634a0a442586b4c543da33d2843a1baa3 --- tests/fate/vcodec.mak| 3 ++- tests/ref/vsynth/vsynth1-ffv1-v2 | 4 tests/ref/vsynth/vsynth2-ffv1-v2 | 4 tests/ref/vsynth/vsynth3-ffv1-v2 | 4 tests/ref/vsynth/vsynth_lena-ffv1-v2 | 4 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/tests/fate/vcodec.mak b/tests/fate/vcodec.mak index abdc481f8a..b9829be027 100644 --- a/tests/fate/vcodec.mak +++ b/tests/fate/vcodec.mak @@ -154,13 +154,14 @@ $(FATE_VCODEC_DV:%=fate-vsynth\%-%): CODEC= dvvideo $(FATE_VCODEC_DV:%=fate-vsynth\%-%): FMT = dv $(FATE_VCODEC_DV:%=fate-vsynth\%-%): DECOPTS += $(DEFAULT_SIZE) -FATE_VCODEC-$(call ENCDEC, FFV1, AVI) += ffv1 ffv1-v0 \ +FATE_VCODEC-$(call ENCDEC, FFV1, AVI) += ffv1 ffv1-v0 ffv1-v2 \ ffv1-v3-yuv420p \ ffv1-2pass FATE_VCODEC_SCALE-$(call ENCDEC, FFV1, AVI) += ffv1-v3-yuv422p10 ffv1-v3-yuv444p16 \ ffv1-v3-bgr0 ffv1-v3-rgb48 fate-vsynth%-ffv1: ENCOPTS = -slices 4 fate-vsynth%-ffv1-v0:CODEC = ffv1 +fate-vsynth%-ffv1-v2:ENCOPTS = -level 2 -strict experimental fate-vsynth%-ffv1-v3-yuv420p:ENCOPTS = -level 3 -pix_fmt yuv420p fate-vsynth%-ffv1-v3-yuv422p10: ENCOPTS = -level 3 -pix_fmt yuv422p10 \ -sws_flags neighbor+bitexact diff --git a/tests/ref/vsynth/vsynth1-ffv1-v2 b/tests/ref/vsynth/vsynth1-ffv1-v2 new file mode 100644 index 00..69536fb390 --- /dev/null +++ b/tests/ref/vsynth/vsynth1-ffv1-v2 @@ -0,0 +1,4 @@ +0f9298229cf53ce257648ccec70c893f *tests/data/fate/vsynth1-ffv1-v2.avi +2689724 tests/data/fate/vsynth1-ffv1-v2.avi +c5ccac874dbf808e9088bc3107860042 *tests/data/fate/vsynth1-ffv1-v2.out.rawvideo +stddev:0.00 PSNR:999.99 MAXDIFF:0 bytes: 7603200/ 7603200 diff --git a/tests/ref/vsynth/vsynth2-ffv1-v2 b/tests/ref/vsynth/vsynth2-ffv1-v2 new file mode 100644 index 00..0b3f288f8f --- /dev/null +++ b/tests/ref/vsynth/vsynth2-ffv1-v2 @@ -0,0 +1,4 @@ +3144d06b9af1af98d072ccf05ff116ba *tests/data/fate/vsynth2-ffv1-v2.avi +3716500 tests/data/fate/vsynth2-ffv1-v2.avi +36d7ca943916e1743cefa609eba0205c *tests/data/fate/vsynth2-ffv1-v2.out.rawvideo +stddev:0.00 PSNR:999.99 MAXDIFF:0 bytes: 7603200/ 7603200 diff --git a/tests/ref/vsynth/vsynth3-ffv1-v2 b/tests/ref/vsynth/vsynth3-ffv1-v2 new file mode 100644 index 00..3b0397ec02 --- /dev/null +++ b/tests/ref/vsynth/vsynth3-ffv1-v2 @@ -0,0 +1,4 @@ +72f1126e9e270f019d90f74959bcf0cb *tests/data/fate/vsynth3-ffv1-v2.avi +60648 tests/data/fate/vsynth3-ffv1-v2.avi +a038ad7c3c09f776304ef7accdea9c74 *tests/data/fate/vsynth3-ffv1-v2.out.rawvideo +stddev:0.00 PSNR:999.99 MAXDIFF:0 bytes:86700/86700 diff --git a/tests/ref/vsynth/vsynth_lena-ffv1-v2 b/tests/ref/vsynth/vsynth_lena-ffv1-v2 new file mode 100644 index 00..5f180462b5 --- /dev/null +++ b/tests/ref/vsynth/vsynth_lena-ffv1-v2 @@ -0,0 +1,4 @@ +4a0dbd5b50fa68fc7d5a8d6d64bd695a *tests/data/fate/vsynth_lena-ffv1-v2.avi +3546264 tests/data/fate/vsynth_lena-ffv1-v2.avi +dde5895817ad9d219f79a52d0bdfb001 *tests/data/fate/vsynth_lena-ffv1-v2.out.rawvideo +stddev:0.00 PSNR:999.99 MAXDIFF:0 bytes: 7603200/ 7603200 ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavc/ffv1dec: declare loop variables in the loop where possible
ffmpeg | branch: master | Anton Khirnov | Wed Jul 3 13:24:23 2024 +0200| [d776fa4e4db4352191f4e6f1fd83c09921e79d25] | committer: Anton Khirnov lavc/ffv1dec: declare loop variables in the loop where possible > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d776fa4e4db4352191f4e6f1fd83c09921e79d25 --- libavcodec/ffv1dec.c | 45 ++--- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index 7a0d1909aa..5c515e97b6 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -46,7 +46,7 @@ static inline av_flatten int get_symbol_inline(RangeCoder *c, uint8_t *state, if (get_rac(c, state + 0)) return 0; else { -int i, e; +int e; unsigned a; e = 0; while (get_rac(c, state + 1 + FFMIN(e, 9))) { // 1..10 @@ -56,7 +56,7 @@ static inline av_flatten int get_symbol_inline(RangeCoder *c, uint8_t *state, } a = 1; -for (i = e - 1; i >= 0; i--) +for (int i = e - 1; i >= 0; i--) a += a + get_rac(c, state + 22 + FFMIN(i, 9)); // 22..31 e = -(is_signed && get_rac(c, state + 11 + FFMIN(e, 10))); // 11..21 @@ -167,7 +167,7 @@ static int decode_slice_header(const FFV1Context *f, FFV1Context *fs) { RangeCoder *c = &fs->c; uint8_t state[CONTEXT_SIZE]; -unsigned ps, i, context_count; +unsigned ps, context_count; int sx, sy, sw, sh; memset(state, 128, sizeof(state)); @@ -197,7 +197,7 @@ static int decode_slice_header(const FFV1Context *f, FFV1Context *fs) if (fs->ac == AC_GOLOMB_RICE && fs->slice_width >= (1<<23)) return AVERROR_INVALIDDATA; -for (i = 0; i < f->plane_count; i++) { +for (unsigned i = 0; i < f->plane_count; i++) { PlaneContext * const p = &fs->plane[i]; int idx = get_symbol(c, state, 0); if (idx >= (unsigned)f->quant_table_count) { @@ -259,7 +259,7 @@ static int decode_slice(AVCodecContext *c, void *arg) int width, height, x, y, ret; const int ps = av_pix_fmt_desc_get(c->pix_fmt)->comp[0].step; AVFrame * const p = f->cur; -int i, si; +int si; for( si=0; fs != f->slice_context[si]; si ++) ; @@ -276,7 +276,7 @@ static int decode_slice(AVCodecContext *c, void *arg) if (!(p->flags & AV_FRAME_FLAG_KEY)) fsdst->slice_damaged |= fssrc->slice_damaged; -for (i = 0; i < f->plane_count; i++) { +for (int i = 0; i < f->plane_count; i++) { PlaneContext *psrc = &fssrc->plane[i]; PlaneContext *pdst = &fsdst->plane[i]; @@ -424,7 +424,7 @@ static int read_extra_header(FFV1Context *f) { RangeCoder *const c = &f->c; uint8_t state[CONTEXT_SIZE]; -int i, j, k, ret; +int ret; uint8_t state2[32][CONTEXT_SIZE]; unsigned crc = 0; @@ -453,7 +453,7 @@ static int read_extra_header(FFV1Context *f) f->ac = get_symbol(c, state, 0); if (f->ac == AC_RANGE_CUSTOM_TAB) { -for (i = 1; i < 256; i++) +for (int i = 1; i < 256; i++) f->state_transition[i] = get_symbol(c, state, 1) + c->one_state[i]; } @@ -492,7 +492,7 @@ static int read_extra_header(FFV1Context *f) return AVERROR_INVALIDDATA; } -for (i = 0; i < f->quant_table_count; i++) { +for (int i = 0; i < f->quant_table_count; i++) { f->context_count[i] = read_quant_tables(c, f->quant_tables[i]); if (f->context_count[i] < 0) { av_log(f->avctx, AV_LOG_ERROR, "read_quant_table error\n"); @@ -502,10 +502,10 @@ static int read_extra_header(FFV1Context *f) if ((ret = ff_ffv1_allocate_initial_states(f)) < 0) return ret; -for (i = 0; i < f->quant_table_count; i++) +for (int i = 0; i < f->quant_table_count; i++) if (get_rac(c, state)) { -for (j = 0; j < f->context_count[i]; j++) -for (k = 0; k < CONTEXT_SIZE; k++) { +for (int j = 0; j < f->context_count[i]; j++) +for (int k = 0; k < CONTEXT_SIZE; k++) { int pred = j ? f->initial_states[i][j - 1][k] : 128; f->initial_states[i][j][k] = (pred + get_symbol(c, state2[k], 1)) & 0xFF; @@ -550,7 +550,7 @@ static int read_extra_header(FFV1Context *f) static int read_header(FFV1Context *f) { uint8_t state[CONTEXT_SIZE]; -int i, j, context_count = -1; //-1 to avoid warning +int context_count = -1; //-1 to avoid warning RangeCoder *const c = &f->slice_context[0]->c; memset(state, 128, sizeof(state)); @@ -566,7 +566,7 @@ static int read_header(FFV1Context *f) f->ac = get_symbol(c, state, 0); if (f->ac == AC_RANGE_CUSTOM_TAB) { -for (i = 1; i < 256; i++) { +for (int i = 1; i < 256; i++) { int st = get_symbol(c, state, 1) + c->one_state[i]; if (st < 1 || st
[FFmpeg-cvslog] lavc/ffv1dec: drop FFV1Context.cur
ffmpeg | branch: master | Anton Khirnov | Wed Jul 3 14:36:02 2024 +0200| [4da146ba831c51b66a038f6a96c8a6b175e55d35] | committer: Anton Khirnov lavc/ffv1dec: drop FFV1Context.cur It is merely a pointer to FFV1Context.picture.f, which can just as well be used directly. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4da146ba831c51b66a038f6a96c8a6b175e55d35 --- libavcodec/ffv1.h| 1 - libavcodec/ffv1dec.c | 33 + 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h index acec22e83e..d99367ce81 100644 --- a/libavcodec/ffv1.h +++ b/libavcodec/ffv1.h @@ -89,7 +89,6 @@ typedef struct FFV1Context { ProgressFrame picture, last_picture; struct FFV1Context *fsrc; -AVFrame *cur; const AVFrame *cur_enc_frame; int plane_count; int ac; ///< 1=range coder <-> 0=golomb rice diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index 7066146477..60d04f04b9 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -163,7 +163,8 @@ static int decode_plane(FFV1Context *s, uint8_t *src, return 0; } -static int decode_slice_header(const FFV1Context *f, FFV1Context *fs) +static int decode_slice_header(const FFV1Context *f, FFV1Context *fs, + AVFrame *frame) { RangeCoder *c = &fs->c; uint8_t state[CONTEXT_SIZE]; @@ -217,23 +218,23 @@ static int decode_slice_header(const FFV1Context *f, FFV1Context *fs) ps = get_symbol(c, state, 0); if (ps == 1) { -f->cur->flags |= AV_FRAME_FLAG_INTERLACED; -f->cur->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST; +frame->flags |= AV_FRAME_FLAG_INTERLACED; +frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST; } else if (ps == 2) { -f->cur->flags |= AV_FRAME_FLAG_INTERLACED; -f->cur->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST; +frame->flags |= AV_FRAME_FLAG_INTERLACED; +frame->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST; } else if (ps == 3) { -f->cur->flags &= ~AV_FRAME_FLAG_INTERLACED; +frame->flags &= ~AV_FRAME_FLAG_INTERLACED; } -f->cur->sample_aspect_ratio.num = get_symbol(c, state, 0); -f->cur->sample_aspect_ratio.den = get_symbol(c, state, 0); +frame->sample_aspect_ratio.num = get_symbol(c, state, 0); +frame->sample_aspect_ratio.den = get_symbol(c, state, 0); if (av_image_check_sar(f->width, f->height, - f->cur->sample_aspect_ratio) < 0) { + frame->sample_aspect_ratio) < 0) { av_log(f->avctx, AV_LOG_WARNING, "ignoring invalid SAR: %u/%u\n", - f->cur->sample_aspect_ratio.num, - f->cur->sample_aspect_ratio.den); -f->cur->sample_aspect_ratio = (AVRational){ 0, 1 }; + frame->sample_aspect_ratio.num, + frame->sample_aspect_ratio.den); +frame->sample_aspect_ratio = (AVRational){ 0, 1 }; } if (fs->version > 3) { @@ -258,7 +259,7 @@ static int decode_slice(AVCodecContext *c, void *arg) FFV1Context *f= fs->avctx->priv_data; int width, height, x, y, ret; const int ps = av_pix_fmt_desc_get(c->pix_fmt)->comp[0].step; -AVFrame * const p = f->cur; +AVFrame * const p = f->picture.f; const int si = (FFV1Context**)arg - f->slice_context; if (f->fsrc && !(p->flags & AV_FRAME_FLAG_KEY) && f->last_picture.f) @@ -299,7 +300,7 @@ static int decode_slice(AVCodecContext *c, void *arg) if (f->version > 2) { if (ff_ffv1_init_slice_state(f, fs) < 0) return AVERROR(ENOMEM); -if (decode_slice_header(f, fs) < 0) { +if (decode_slice_header(f, fs, p) < 0) { fs->slice_x = fs->slice_y = fs->slice_height = fs->slice_width = 0; fs->slice_damaged = 1; return AVERROR_INVALIDDATA; @@ -307,7 +308,7 @@ static int decode_slice(AVCodecContext *c, void *arg) } if ((ret = ff_ffv1_init_slice_state(f, fs)) < 0) return ret; -if ((f->cur->flags & AV_FRAME_FLAG_KEY) || fs->slice_reset_contexts) { +if ((p->flags & AV_FRAME_FLAG_KEY) || fs->slice_reset_contexts) { ff_ffv1_clear_slice_state(f, fs); } else if (fs->slice_damaged) { return AVERROR_INVALIDDATA; @@ -920,7 +921,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe, if (ret < 0) return ret; -f->cur = p = f->picture.f; +p = f->picture.f; p->pict_type = AV_PICTURE_TYPE_I; //FIXME I vs. P p->flags = (p->flags & ~AV_FRAME_FLAG_KEY) | key_frame; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavc/ffv1dec: drop a pointless variable in decode_slice()
ffmpeg | branch: master | Anton Khirnov | Wed Jul 3 14:40:23 2024 +0200| [3a5c814b19191022affa76e282b69b9aca8883ba] | committer: Anton Khirnov lavc/ffv1dec: drop a pointless variable in decode_slice() fsdst is by construction always equal to fs, there is even an av_assert1() checking that. Just use fs directly. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3a5c814b19191022affa76e282b69b9aca8883ba --- libavcodec/ffv1dec.c | 8 +++- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index 60d04f04b9..dbb7e082a3 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -267,16 +267,14 @@ static int decode_slice(AVCodecContext *c, void *arg) if(f->fsrc && !(p->flags & AV_FRAME_FLAG_KEY)) { FFV1Context *fssrc = f->fsrc->slice_context[si]; -FFV1Context *fsdst = f->slice_context[si]; -av_assert1(fsdst->plane_count == fssrc->plane_count); -av_assert1(fsdst == fs); +av_assert1(fs->plane_count == fssrc->plane_count); if (!(p->flags & AV_FRAME_FLAG_KEY)) -fsdst->slice_damaged |= fssrc->slice_damaged; +fs->slice_damaged |= fssrc->slice_damaged; for (int i = 0; i < f->plane_count; i++) { PlaneContext *psrc = &fssrc->plane[i]; -PlaneContext *pdst = &fsdst->plane[i]; +PlaneContext *pdst = &fs->plane[i]; av_free(pdst->state); av_free(pdst->vlc_state); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavc/ffv1: add a per-slice context
ffmpeg | branch: master | Anton Khirnov | Thu Jul 4 10:22:53 2024 +0200| [54aa33f116b9451a50a39cffd5cec5bfd21a47a8] | committer: Anton Khirnov lavc/ffv1: add a per-slice context FFV1 decoder and encoder currently use the same struct - FFV1Context - both as codec private data and per-slice context. For this purpose FFV1Context contains an array of pointers to per-slice FFV1Context instances. This pattern is highly confusing, as it is not clear which fields are per-slice and which per-codec. Address this by adding a new struct storing only per-slice data. Start by moving slice_{x,y,width,height} to it. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=54aa33f116b9451a50a39cffd5cec5bfd21a47a8 --- libavcodec/ffv1.c| 15 --- libavcodec/ffv1.h| 13 ++--- libavcodec/ffv1dec.c | 76 +--- libavcodec/ffv1enc.c | 25 + 4 files changed, 76 insertions(+), 53 deletions(-) diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c index 6ec24fed4a..25f28287c0 100644 --- a/libavcodec/ffv1.c +++ b/libavcodec/ffv1.c @@ -108,7 +108,12 @@ av_cold int ff_ffv1_init_slice_contexts(FFV1Context *f) av_assert0(max_slice_count > 0); +f->slices = av_calloc(max_slice_count, sizeof(*f->slices)); +if (!f->slices) +return AVERROR(ENOMEM); + for (i = 0; i < max_slice_count;) { +FFV1SliceContext *sc = &f->slices[i]; int sx = i % f->num_h_slices; int sy = i / f->num_h_slices; int sxs = f->avctx->width * sx / f->num_h_slices; @@ -124,10 +129,10 @@ av_cold int ff_ffv1_init_slice_contexts(FFV1Context *f) memcpy(fs, f, sizeof(*fs)); memset(fs->rc_stat2, 0, sizeof(fs->rc_stat2)); -fs->slice_width = sxe - sxs; -fs->slice_height = sye - sys; -fs->slice_x = sxs; -fs->slice_y = sys; +sc->slice_width = sxe - sxs; +sc->slice_height = sye - sys; +sc->slice_x = sxs; +sc->slice_y = sys; fs->sample_buffer = av_malloc_array((fs->width + 6), 3 * MAX_PLANES * sizeof(*fs->sample_buffer)); @@ -217,5 +222,7 @@ av_cold int ff_ffv1_close(AVCodecContext *avctx) for (i = 0; i < s->max_slice_count; i++) av_freep(&s->slice_context[i]); +av_freep(&s->slices); + return 0; } diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h index d99367ce81..256904b283 100644 --- a/libavcodec/ffv1.h +++ b/libavcodec/ffv1.h @@ -69,6 +69,13 @@ typedef struct PlaneContext { #define MAX_SLICES 1024 +typedef struct FFV1SliceContext { +int slice_width; +int slice_height; +int slice_x; +int slice_y; +} FFV1SliceContext; + typedef struct FFV1Context { AVClass *class; AVCodecContext *avctx; @@ -123,14 +130,12 @@ typedef struct FFV1Context { int max_slice_count; int num_v_slices; int num_h_slices; -int slice_width; -int slice_height; -int slice_x; -int slice_y; int slice_reset_contexts; int slice_coding_mode; int slice_rct_by_coef; int slice_rct_ry_coef; + +FFV1SliceContext *slices; } FFV1Context; int ff_ffv1_common_init(AVCodecContext *avctx); diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index 6d59355c23..28e4a05b21 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -164,7 +164,7 @@ static int decode_plane(FFV1Context *s, uint8_t *src, } static int decode_slice_header(const FFV1Context *f, FFV1Context *fs, - AVFrame *frame) + FFV1SliceContext *sc, AVFrame *frame) { RangeCoder *c = &fs->c; uint8_t state[CONTEXT_SIZE]; @@ -185,17 +185,17 @@ static int decode_slice_header(const FFV1Context *f, FFV1Context *fs, if (sx > f->num_h_slices - sw || sy > f->num_v_slices - sh) return AVERROR_INVALIDDATA; -fs->slice_x = sx * (int64_t)f->width / f->num_h_slices; -fs->slice_y = sy * (int64_t)f->height / f->num_v_slices; -fs->slice_width = (sx + sw) * (int64_t)f->width / f->num_h_slices - fs->slice_x; -fs->slice_height = (sy + sh) * (int64_t)f->height / f->num_v_slices - fs->slice_y; +sc->slice_x = sx * (int64_t)f->width / f->num_h_slices; +sc->slice_y = sy * (int64_t)f->height / f->num_v_slices; +sc->slice_width = (sx + sw) * (int64_t)f->width / f->num_h_slices - sc->slice_x; +sc->slice_height = (sy + sh) * (int64_t)f->height / f->num_v_slices - sc->slice_y; -av_assert0((unsigned)fs->slice_width <= f->width && -(unsigned)fs->slice_height <= f->height); -av_assert0 ( (unsigned)fs->slice_x + (uint64_t)fs->slice_width <= f->width -&& (unsigned)fs->slice_y + (uint64_t)fs->slice_height <= f->height); +av_assert0((unsigned)sc->slice_width <= f->width && +(unsigned)sc->slice_height <=
[FFmpeg-cvslog] lavc/ffv1dec: simplify slice index calculation
ffmpeg | branch: master | Anton Khirnov | Wed Jul 3 13:24:23 2024 +0200| [e1fa107fd1ac22f3f34c2bc5367a7055da784499] | committer: Anton Khirnov lavc/ffv1dec: simplify slice index calculation > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e1fa107fd1ac22f3f34c2bc5367a7055da784499 --- libavcodec/ffv1dec.c | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index 5c515e97b6..7066146477 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -259,10 +259,7 @@ static int decode_slice(AVCodecContext *c, void *arg) int width, height, x, y, ret; const int ps = av_pix_fmt_desc_get(c->pix_fmt)->comp[0].step; AVFrame * const p = f->cur; -int si; - -for( si=0; fs != f->slice_context[si]; si ++) -; +const int si = (FFV1Context**)arg - f->slice_context; if (f->fsrc && !(p->flags & AV_FRAME_FLAG_KEY) && f->last_picture.f) ff_progress_frame_await(&f->last_picture, si); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavc/ffv1dec: move copy_fields() under HAVE_THREADS
ffmpeg | branch: master | Anton Khirnov | Wed Jul 3 14:54:51 2024 +0200| [d845ea49c5b6039df18f935103cbef588f223799] | committer: Anton Khirnov lavc/ffv1dec: move copy_fields() under HAVE_THREADS It is unused otherwise > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d845ea49c5b6039df18f935103cbef588f223799 --- libavcodec/ffv1dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index dbb7e082a3..6d59355c23 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -1027,6 +1027,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe, return buf_size; } +#if HAVE_THREADS static void copy_fields(FFV1Context *fsdst, const FFV1Context *fssrc, const FFV1Context *fsrc) { @@ -1055,7 +1056,6 @@ static void copy_fields(FFV1Context *fsdst, const FFV1Context *fssrc, } } -#if HAVE_THREADS static int update_thread_context(AVCodecContext *dst, const AVCodecContext *src) { FFV1Context *fsrc = src->priv_data; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavc/ffv1: move run_index to the per-slice context
ffmpeg | branch: master | Anton Khirnov | Sun Jul 7 19:46:20 2024 +0200| [19e9f3d5f2457da9b0b9b3d60f2df454580f9f21] | committer: Anton Khirnov lavc/ffv1: move run_index to the per-slice context > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=19e9f3d5f2457da9b0b9b3d60f2df454580f9f21 --- libavcodec/ffv1.h | 3 ++- libavcodec/ffv1dec.c | 6 +++--- libavcodec/ffv1dec_template.c | 16 libavcodec/ffv1enc.c | 6 +++--- libavcodec/ffv1enc_template.c | 16 5 files changed, 24 insertions(+), 23 deletions(-) diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h index ccb510a483..68d13a2964 100644 --- a/libavcodec/ffv1.h +++ b/libavcodec/ffv1.h @@ -77,6 +77,8 @@ typedef struct FFV1SliceContext { int slice_height; int slice_x; int slice_y; + +int run_index; } FFV1SliceContext; typedef struct FFV1Context { @@ -109,7 +111,6 @@ typedef struct FFV1Context { int context_count[MAX_QUANT_TABLES]; uint8_t state_transition[256]; uint8_t (*initial_states[MAX_QUANT_TABLES])[32]; -int run_index; int colorspace; int use32bit; diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index fcf8977a36..a2971d7eea 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -126,7 +126,7 @@ static int decode_plane(FFV1Context *s, FFV1SliceContext *sc, sample[0] = sc->sample_buffer + 3; sample[1] = sc->sample_buffer + w + 6 + 3; -s->run_index = 0; +sc->run_index = 0; memset(sc->sample_buffer, 0, 2 * (w + 6) * sizeof(*sc->sample_buffer)); @@ -140,13 +140,13 @@ static int decode_plane(FFV1Context *s, FFV1SliceContext *sc, sample[0][w] = sample[0][w - 1]; if (s->avctx->bits_per_raw_sample <= 8) { -int ret = decode_line(s, w, sample, plane_index, 8); +int ret = decode_line(s, sc, w, sample, plane_index, 8); if (ret < 0) return ret; for (x = 0; x < w; x++) src[x*pixel_stride + stride * y] = sample[1][x]; } else { -int ret = decode_line(s, w, sample, plane_index, s->avctx->bits_per_raw_sample); +int ret = decode_line(s, sc, w, sample, plane_index, s->avctx->bits_per_raw_sample); if (ret < 0) return ret; if (s->packed_at_lsb) { diff --git a/libavcodec/ffv1dec_template.c b/libavcodec/ffv1dec_template.c index b9316e04ca..8e2e38c0b9 100644 --- a/libavcodec/ffv1dec_template.c +++ b/libavcodec/ffv1dec_template.c @@ -22,16 +22,16 @@ #include "ffv1_template.c" -static av_always_inline int RENAME(decode_line)(FFV1Context *s, int w, - TYPE *sample[2], - int plane_index, int bits) +static av_always_inline int +RENAME(decode_line)(FFV1Context *s, FFV1SliceContext *sc, int w, +TYPE *sample[2], int plane_index, int bits) { PlaneContext *const p = &s->plane[plane_index]; RangeCoder *const c = &s->c; int x; int run_count = 0; int run_mode = 0; -int run_index = s->run_index; +int run_index = sc->run_index; if (is_input_end(s)) return AVERROR_INVALIDDATA; @@ -123,7 +123,7 @@ static av_always_inline int RENAME(decode_line)(FFV1Context *s, int w, sample[1][x] = av_zero_extend(RENAME(predict)(sample[1] + x, sample[0] + x) + (SUINT)diff, bits); } -s->run_index = run_index; +sc->run_index = run_index; return 0; } @@ -142,7 +142,7 @@ static int RENAME(decode_rgb_frame)(FFV1Context *s, FFV1SliceContext *sc, sample[x][1] = RENAME(sc->sample_buffer) + (x * 2 + 1) * (w + 6) + 3; } -s->run_index = 0; +sc->run_index = 0; memset(RENAME(sc->sample_buffer), 0, 8 * (w + 6) * sizeof(*RENAME(sc->sample_buffer))); @@ -157,9 +157,9 @@ static int RENAME(decode_rgb_frame)(FFV1Context *s, FFV1SliceContext *sc, sample[p][1][-1]= sample[p][0][0 ]; sample[p][0][ w]= sample[p][0][w-1]; if (lbd && s->slice_coding_mode == 0) -ret = RENAME(decode_line)(s, w, sample[p], (p + 1)/2, 9); +ret = RENAME(decode_line)(s, sc, w, sample[p], (p + 1)/2, 9); else -ret = RENAME(decode_line)(s, w, sample[p], (p + 1)/2, bits + (s->slice_coding_mode != 1)); +ret = RENAME(decode_line)(s, sc, w, sample[p], (p + 1)/2, bits + (s->slice_coding_mode != 1)); if (ret < 0) return ret; } diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c index f6b1919ee4..8bb9174a1d 100644 --- a/libavcodec/ffv1enc.c +++ b/libavcodec/ffv1enc.c @@ -276,7 +276,7 @@ static int encode_plane(FFV1Context *s, FFV1SliceContext *sc, int x, y, i, ret; const int ring_size = s->context_model ? 3 : 2; int16_t *sample[3]; -s->run_index = 0; +sc->run_index = 0; memset(
[FFmpeg-cvslog] lavc/ffv1: move sample_buffer to the per-slice context
ffmpeg | branch: master | Anton Khirnov | Sun Jul 7 19:46:20 2024 +0200| [91d3c1ac47d4a2b1455945b6131a44cdc5e7f425] | committer: Anton Khirnov lavc/ffv1: move sample_buffer to the per-slice context > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=91d3c1ac47d4a2b1455945b6131a44cdc5e7f425 --- libavcodec/ffv1.c | 35 --- libavcodec/ffv1.h | 5 +++-- libavcodec/ffv1dec.c | 27 +-- libavcodec/ffv1dec_template.c | 9 + libavcodec/ffv1enc.c | 30 -- libavcodec/ffv1enc_template.c | 9 + 6 files changed, 62 insertions(+), 53 deletions(-) diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c index 25f28287c0..a102425596 100644 --- a/libavcodec/ffv1.c +++ b/libavcodec/ffv1.c @@ -112,6 +112,8 @@ av_cold int ff_ffv1_init_slice_contexts(FFV1Context *f) if (!f->slices) return AVERROR(ENOMEM); +f->max_slice_count = max_slice_count; + for (i = 0; i < max_slice_count;) { FFV1SliceContext *sc = &f->slices[i]; int sx = i % f->num_h_slices; @@ -123,7 +125,7 @@ av_cold int ff_ffv1_init_slice_contexts(FFV1Context *f) FFV1Context *fs = av_mallocz(sizeof(*fs)); if (!fs) -goto memfail; +return AVERROR(ENOMEM); f->slice_context[i++] = fs; memcpy(fs, f, sizeof(*fs)); @@ -134,19 +136,15 @@ av_cold int ff_ffv1_init_slice_contexts(FFV1Context *f) sc->slice_x = sxs; sc->slice_y = sys; -fs->sample_buffer = av_malloc_array((fs->width + 6), 3 * MAX_PLANES * - sizeof(*fs->sample_buffer)); -fs->sample_buffer32 = av_malloc_array((fs->width + 6), 3 * MAX_PLANES * -sizeof(*fs->sample_buffer32)); -if (!fs->sample_buffer || !fs->sample_buffer32) -goto memfail; +sc->sample_buffer = av_malloc_array((fs->width + 6), 3 * MAX_PLANES * +sizeof(*sc->sample_buffer)); +sc->sample_buffer32 = av_malloc_array((fs->width + 6), 3 * MAX_PLANES * + sizeof(*sc->sample_buffer32)); +if (!sc->sample_buffer || !sc->sample_buffer32) +return AVERROR(ENOMEM); } -f->max_slice_count = max_slice_count; -return 0; -memfail: -f->max_slice_count = i; -return AVERROR(ENOMEM); +return 0; } int ff_ffv1_allocate_initial_states(FFV1Context *f) @@ -199,14 +197,20 @@ av_cold int ff_ffv1_close(AVCodecContext *avctx) for (j = 0; j < s->max_slice_count; j++) { FFV1Context *fs = s->slice_context[j]; +FFV1SliceContext *sc = &s->slices[j]; + +av_freep(&sc->sample_buffer); +av_freep(&sc->sample_buffer32); + +if (!fs) +continue; + for (i = 0; i < s->plane_count; i++) { PlaneContext *p = &fs->plane[i]; av_freep(&p->state); av_freep(&p->vlc_state); } -av_freep(&fs->sample_buffer); -av_freep(&fs->sample_buffer32); } av_freep(&avctx->stats_out); @@ -214,7 +218,8 @@ av_cold int ff_ffv1_close(AVCodecContext *avctx) av_freep(&s->initial_states[j]); for (i = 0; i < s->max_slice_count; i++) { FFV1Context *sf = s->slice_context[i]; -av_freep(&sf->rc_stat2[j]); +if (sf) +av_freep(&sf->rc_stat2[j]); } av_freep(&s->rc_stat2[j]); } diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h index 256904b283..ccb510a483 100644 --- a/libavcodec/ffv1.h +++ b/libavcodec/ffv1.h @@ -70,6 +70,9 @@ typedef struct PlaneContext { #define MAX_SLICES 1024 typedef struct FFV1SliceContext { +int16_t *sample_buffer; +int32_t *sample_buffer32; + int slice_width; int slice_height; int slice_x; @@ -108,8 +111,6 @@ typedef struct FFV1Context { uint8_t (*initial_states[MAX_QUANT_TABLES])[32]; int run_index; int colorspace; -int16_t *sample_buffer; -int32_t *sample_buffer32; int use32bit; diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index 28e4a05b21..fcf8977a36 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -117,18 +117,18 @@ static int is_input_end(FFV1Context *s) #define RENAME(name) name ## 32 #include "ffv1dec_template.c" -static int decode_plane(FFV1Context *s, uint8_t *src, - int w, int h, int stride, int plane_index, +static int decode_plane(FFV1Context *s, FFV1SliceContext *sc, +uint8_t *src, int w, int h, int stride, int plane_index, int pixel_stride) { int x, y; int16_t *sample[2]; -sample[0] = s->sample_buffer + 3; -sample[1] = s->sample_buffer + w + 6 + 3; +sample[0] = sc->sample_buffer + 3; +sample[1] = sc->sample_buffer + w + 6
[FFmpeg-cvslog] lavc/ffv1enc: move bit writer to per-slice context
ffmpeg | branch: master | Anton Khirnov | Mon Jul 8 10:14:55 2024 +0200| [d2f507233a6c3cbc24d342d3c31db2c3489df96d] | committer: Anton Khirnov lavc/ffv1enc: move bit writer to per-slice context > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d2f507233a6c3cbc24d342d3c31db2c3489df96d --- 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; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavc/ffv1: drop redundant FFV1Context.quant_table
ffmpeg | branch: master | Anton Khirnov | Mon Jul 8 11:36:58 2024 +0200| [4b9f7c7e3a9568a1982a6618c0ab77a3695675c1] | committer: Anton Khirnov lavc/ffv1: drop redundant FFV1Context.quant_table In all cases except decoding version 1 it's either not used, or contains a copy of a table from quant_tables, which we can just as well use directly. When decoding version 1, we can just as well decode into quant_tables[0], which would otherwise be unused. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4b9f7c7e3a9568a1982a6618c0ab77a3695675c1 --- libavcodec/ffv1.h| 1 - libavcodec/ffv1dec.c | 10 +++--- libavcodec/ffv1enc.c | 6 ++ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h index dce6e177eb..4d57172d5b 100644 --- a/libavcodec/ffv1.h +++ b/libavcodec/ffv1.h @@ -106,7 +106,6 @@ typedef struct FFV1Context { int ac; ///< 1=range coder <-> 0=golomb rice int ac_byte_count; ///< number of bytes used for AC coding PlaneContext plane[MAX_PLANES]; -int16_t quant_table[MAX_CONTEXT_INPUTS][256]; int16_t quant_tables[MAX_QUANT_TABLES][MAX_CONTEXT_INPUTS][256]; int context_count[MAX_QUANT_TABLES]; uint8_t state_transition[256]; diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index a1f7206871..66d9f63c1a 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -764,7 +764,7 @@ static int read_header(FFV1Context *f) ff_dlog(f->avctx, "%d %d %d\n", f->chroma_h_shift, f->chroma_v_shift, f->avctx->pix_fmt); if (f->version < 2) { -context_count = read_quant_tables(c, f->quant_table); +context_count = read_quant_tables(c, f->quant_tables[0]); if (context_count < 0) { av_log(f->avctx, AV_LOG_ERROR, "read_quant_table error\n"); return AVERROR_INVALIDDATA; @@ -834,7 +834,7 @@ static int read_header(FFV1Context *f) sizeof(p->quant_table)); context_count = f->context_count[idx]; } else { -memcpy(p->quant_table, f->quant_table, sizeof(p->quant_table)); +memcpy(p->quant_table, f->quant_tables[0], sizeof(p->quant_table)); } if (f->version <= 2) { @@ -1067,7 +1067,11 @@ static int update_thread_context(AVCodecContext *dst, const AVCodecContext *src) fdst->use32bit = fsrc->use32bit; memcpy(fdst->state_transition, fsrc->state_transition, sizeof(fdst->state_transition)); -memcpy(fdst->quant_table, fsrc->quant_table, sizeof(fsrc->quant_table)); + +// in version 1 there is a single per-keyframe quant table, so +// we need to propagate it between threads +if (fsrc->version < 2) +memcpy(fdst->quant_tables[0], fsrc->quant_tables[0], sizeof(fsrc->quant_tables[0])); for (int i = 0; i < fdst->num_h_slices * fdst->num_v_slices; i++) { FFV1Context *fssrc = fsrc->slice_context[i]; diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c index 5692bfa1fc..1d00a46cdd 100644 --- a/libavcodec/ffv1enc.c +++ b/libavcodec/ffv1enc.c @@ -367,7 +367,7 @@ static void write_header(FFV1Context *f) put_symbol(c, state, f->chroma_v_shift, 0); put_rac(c, state, f->transparency); -write_quant_tables(c, f->quant_table); +write_quant_tables(c, f->quant_tables[f->context_model]); } else if (f->version < 3) { put_symbol(c, state, f->slice_count, 0); for (i = 0; i < f->slice_count; i++) { @@ -735,15 +735,13 @@ static av_cold int encode_init(AVCodecContext *avctx) } 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[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 = s->context_model; p->context_count = s->context_count[p->quant_table_index]; +memcpy(p->quant_table, s->quant_tables[p->quant_table_index], sizeof(p->quant_table)); } if ((ret = ff_ffv1_allocate_initial_states(s)) < 0) ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavc/ffv1: drop write-only PlaneContext.interlace_bit_state
ffmpeg | branch: master | Anton Khirnov | Mon Jul 8 12:46:29 2024 +0200| [492df6520128f00e341999f454ea9986da2c9a11] | committer: Anton Khirnov lavc/ffv1: drop write-only PlaneContext.interlace_bit_state > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=492df6520128f00e341999f454ea9986da2c9a11 --- libavcodec/ffv1.c | 3 --- libavcodec/ffv1.h | 1 - 2 files changed, 4 deletions(-) diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c index a102425596..6a0aca6429 100644 --- a/libavcodec/ffv1.c +++ b/libavcodec/ffv1.c @@ -169,9 +169,6 @@ void ff_ffv1_clear_slice_state(const FFV1Context *f, FFV1Context *fs) for (i = 0; i < f->plane_count; i++) { PlaneContext *p = &fs->plane[i]; -p->interlace_bit_state[0] = 128; -p->interlace_bit_state[1] = 128; - if (fs->ac != AC_GOLOMB_RICE) { if (f->initial_states[p->quant_table_index]) { memcpy(p->state, f->initial_states[p->quant_table_index], diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h index a87c2d2a36..a3f3b30b49 100644 --- a/libavcodec/ffv1.h +++ b/libavcodec/ffv1.h @@ -63,7 +63,6 @@ typedef struct PlaneContext { int context_count; uint8_t (*state)[CONTEXT_SIZE]; VlcState *vlc_state; -uint8_t interlace_bit_state[2]; } PlaneContext; #define MAX_SLICES 1024 ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavc/ffv1dec: move the bitreader to stack
ffmpeg | branch: master | Anton Khirnov | Mon Jul 8 10:09:22 2024 +0200| [889faedd26ed627f0f21e7b6c0ff438edde4f77f] | committer: Anton Khirnov lavc/ffv1dec: move the bitreader to stack There is no reason to place it in persistent state. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=889faedd26ed627f0f21e7b6c0ff438edde4f77f --- libavcodec/ffv1.h | 1 - libavcodec/ffv1dec.c | 28 +++- libavcodec/ffv1dec_template.c | 23 --- 3 files changed, 27 insertions(+), 25 deletions(-) diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h index 68d13a2964..c88aa8c30d 100644 --- a/libavcodec/ffv1.h +++ b/libavcodec/ffv1.h @@ -85,7 +85,6 @@ typedef struct FFV1Context { AVClass *class; AVCodecContext *avctx; RangeCoder c; -GetBitContext gb; PutBitContext pb; uint64_t rc_stat[256][2]; uint64_t (*rc_stat2[MAX_QUANT_TABLES])[32][2]; diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index a2971d7eea..a1f7206871 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -94,14 +94,14 @@ static inline int get_vlc_symbol(GetBitContext *gb, VlcState *const state, return ret; } -static int is_input_end(FFV1Context *s) +static int is_input_end(FFV1Context *s, GetBitContext *gb) { if (s->ac != AC_GOLOMB_RICE) { RangeCoder *const c = &s->c; if (c->overread > MAX_OVERREAD) return AVERROR_INVALIDDATA; } else { -if (get_bits_left(&s->gb) < 1) +if (get_bits_left(gb) < 1) return AVERROR_INVALIDDATA; } return 0; @@ -118,6 +118,7 @@ static int is_input_end(FFV1Context *s) #include "ffv1dec_template.c" static int decode_plane(FFV1Context *s, FFV1SliceContext *sc, +GetBitContext *gb, uint8_t *src, int w, int h, int stride, int plane_index, int pixel_stride) { @@ -140,13 +141,13 @@ static int decode_plane(FFV1Context *s, FFV1SliceContext *sc, sample[0][w] = sample[0][w - 1]; if (s->avctx->bits_per_raw_sample <= 8) { -int ret = decode_line(s, sc, w, sample, plane_index, 8); +int ret = decode_line(s, sc, gb, w, sample, plane_index, 8); if (ret < 0) return ret; for (x = 0; x < w; x++) src[x*pixel_stride + stride * y] = sample[1][x]; } else { -int ret = decode_line(s, sc, w, sample, plane_index, s->avctx->bits_per_raw_sample); +int ret = decode_line(s, sc, gb, w, sample, plane_index, s->avctx->bits_per_raw_sample); if (ret < 0) return ret; if (s->packed_at_lsb) { @@ -262,6 +263,7 @@ static int decode_slice(AVCodecContext *c, void *arg) AVFrame * const p = f->picture.f; const int si = (FFV1Context**)arg - f->slice_context; FFV1SliceContext *sc = &f->slices[si]; +GetBitContext gb; if (f->fsrc && !(p->flags & AV_FRAME_FLAG_KEY) && f->last_picture.f) ff_progress_frame_await(&f->last_picture, si); @@ -322,7 +324,7 @@ static int decode_slice(AVCodecContext *c, void *arg) if (f->version == 3 && f->micro_version > 1 || f->version > 3) get_rac(&fs->c, (uint8_t[]) { 129 }); fs->ac_byte_count = f->version > 2 || (!x && !y) ? fs->c.bytestream - fs->c.bytestream_start - 1 : 0; -init_get_bits(&fs->gb, +init_get_bits(&gb, fs->c.bytestream_start + fs->ac_byte_count, (fs->c.bytestream_end - fs->c.bytestream_start - fs->ac_byte_count) * 8); } @@ -333,29 +335,29 @@ static int decode_slice(AVCodecContext *c, void *arg) const int chroma_height = AV_CEIL_RSHIFT(height, f->chroma_v_shift); const int cx= x >> f->chroma_h_shift; const int cy= y >> f->chroma_v_shift; -decode_plane(fs, sc, p->data[0] + ps*x + y*p->linesize[0], width, height, p->linesize[0], 0, 1); +decode_plane(fs, sc, &gb, p->data[0] + ps*x + y*p->linesize[0], width, height, p->linesize[0], 0, 1); if (f->chroma_planes) { -decode_plane(fs, sc, p->data[1] + ps*cx+cy*p->linesize[1], chroma_width, chroma_height, p->linesize[1], 1, 1); -decode_plane(fs, sc, p->data[2] + ps*cx+cy*p->linesize[2], chroma_width, chroma_height, p->linesize[2], 1, 1); +decode_plane(fs, sc, &gb, p->data[1] + ps*cx+cy*p->linesize[1], chroma_width, chroma_height, p->linesize[1], 1, 1); +decode_plane(fs, sc, &gb, p->data[2] + ps*cx+cy*p->linesize[2], chroma_width, chroma_height, p->linesize[2], 1, 1); } if (fs->transparency) -decode_plane(fs, sc, p->data[3] + ps*x + y*p->linesize[3], width, height, p->linesize[3], (f->version >= 4 && !f->chroma_planes) ? 1 : 2, 1); +decode_plane(fs, sc, &gb, p->data[3] + ps*x + y*p->linesize[3], width, height, p->line
[FFmpeg-cvslog] lavc/ffv1: always use the main context values of plane_count/transparency
ffmpeg | branch: master | Anton Khirnov | Mon Jul 8 13:11:52 2024 +0200| [39486a2b29dc893b295bc328c63ec138a2df3a91] | committer: Anton Khirnov lavc/ffv1: always use the main context values of plane_count/transparency They cannot change between slices. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=39486a2b29dc893b295bc328c63ec138a2df3a91 --- libavcodec/ffv1.c | 2 -- libavcodec/ffv1dec.c | 5 ++--- libavcodec/ffv1dec_template.c | 2 +- libavcodec/ffv1enc.c | 2 +- libavcodec/ffv1enc_template.c | 2 +- 5 files changed, 5 insertions(+), 8 deletions(-) diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c index 6a0aca6429..06a77c3a26 100644 --- a/libavcodec/ffv1.c +++ b/libavcodec/ffv1.c @@ -56,8 +56,6 @@ av_cold int ff_ffv1_init_slice_state(const FFV1Context *f, FFV1Context *fs) { int j, i; -fs->plane_count = f->plane_count; -fs->transparency = f->transparency; for (j = 0; j < f->plane_count; j++) { PlaneContext *const p = &fs->plane[j]; diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index 618020d10f..6d3db25279 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -270,7 +270,6 @@ static int decode_slice(AVCodecContext *c, void *arg) if(f->fsrc && !(p->flags & AV_FRAME_FLAG_KEY)) { FFV1Context *fssrc = f->fsrc->slice_context[si]; -av_assert1(fs->plane_count == fssrc->plane_count); if (!(p->flags & AV_FRAME_FLAG_KEY)) fs->slice_damaged |= fssrc->slice_damaged; @@ -330,7 +329,7 @@ static int decode_slice(AVCodecContext *c, void *arg) } av_assert1(width && height); -if (f->colorspace == 0 && (f->chroma_planes || !fs->transparency)) { +if (f->colorspace == 0 && (f->chroma_planes || !f->transparency)) { const int chroma_width = AV_CEIL_RSHIFT(width, f->chroma_h_shift); const int chroma_height = AV_CEIL_RSHIFT(height, f->chroma_v_shift); const int cx= x >> f->chroma_h_shift; @@ -341,7 +340,7 @@ static int decode_slice(AVCodecContext *c, void *arg) decode_plane(f, fs, sc, &gb, p->data[1] + ps*cx+cy*p->linesize[1], chroma_width, chroma_height, p->linesize[1], 1, 1); decode_plane(f, fs, sc, &gb, p->data[2] + ps*cx+cy*p->linesize[2], chroma_width, chroma_height, p->linesize[2], 1, 1); } -if (fs->transparency) +if (f->transparency) decode_plane(f, fs, sc, &gb, p->data[3] + ps*x + y*p->linesize[3], width, height, p->linesize[3], (f->version >= 4 && !f->chroma_planes) ? 1 : 2, 1); } else if (f->colorspace == 0) { decode_plane(f, fs, sc, &gb, p->data[0] + ps*x + y*p->linesize[0] , width, height, p->linesize[0], 0, 2); diff --git a/libavcodec/ffv1dec_template.c b/libavcodec/ffv1dec_template.c index d68bbda5be..5c472168e2 100644 --- a/libavcodec/ffv1dec_template.c +++ b/libavcodec/ffv1dec_template.c @@ -141,7 +141,7 @@ static int RENAME(decode_rgb_frame)(FFV1Context *f, int lbd= s->avctx->bits_per_raw_sample <= 8; int bits = s->avctx->bits_per_raw_sample > 0 ? s->avctx->bits_per_raw_sample : 8; int offset = 1 << bits; -int transparency = s->transparency; +int transparency = f->transparency; for (x = 0; x < 4; x++) { sample[x][0] = RENAME(sc->sample_buffer) + x * 2 * (w + 6) + 3; diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c index 714e007659..d334220e13 100644 --- a/libavcodec/ffv1enc.c +++ b/libavcodec/ffv1enc.c @@ -1072,7 +1072,7 @@ retry: ret |= encode_plane(f, fs, sc, p->data[1] + ps*cx+cy*p->linesize[1], chroma_width, chroma_height, p->linesize[1], 1, 1); ret |= encode_plane(f, fs, sc, p->data[2] + ps*cx+cy*p->linesize[2], chroma_width, chroma_height, p->linesize[2], 1, 1); } -if (fs->transparency) +if (f->transparency) ret |= encode_plane(f, fs, sc, p->data[3] + ps*x + y*p->linesize[3], width, height, p->linesize[3], 2, 1); } else if (c->pix_fmt == AV_PIX_FMT_YA8) { ret = encode_plane(f, fs, sc, p->data[0] + ps*x + y*p->linesize[0], width, height, p->linesize[0], 0, 2); diff --git a/libavcodec/ffv1enc_template.c b/libavcodec/ffv1enc_template.c index 4a5580e1a5..0f47a0b424 100644 --- a/libavcodec/ffv1enc_template.c +++ b/libavcodec/ffv1enc_template.c @@ -138,7 +138,7 @@ static int RENAME(encode_rgb_frame)(FFV1Context *f, int packed = !src[1]; int bits = s->bits_per_raw_sample > 0 ? s->bits_per_raw_sample : 8; int offset = 1 << bits; -int transparency = s->transparency; +int transparency = f->transparency; int packed_size = (3 + transparency)*2; sc->run_index = 0; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavc/ffv1: move FFV1Context.slice_{coding_mode,rct_.y_coef} to per-slice context
ffmpeg | branch: master | Anton Khirnov | Mon Jul 8 16:11:25 2024 +0200| [a57c88d67b921a086d8efc3810e5b749661120d1] | committer: Anton Khirnov lavc/ffv1: move FFV1Context.slice_{coding_mode,rct_.y_coef} to per-slice context > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a57c88d67b921a086d8efc3810e5b749661120d1 --- libavcodec/ffv1.h | 6 +++--- libavcodec/ffv1dec.c | 14 +++--- libavcodec/ffv1dec_template.c | 10 +- libavcodec/ffv1enc.c | 26 +- libavcodec/ffv1enc_template.c | 10 +- 5 files changed, 33 insertions(+), 33 deletions(-) diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h index a3f3b30b49..e466aedbbe 100644 --- a/libavcodec/ffv1.h +++ b/libavcodec/ffv1.h @@ -77,6 +77,9 @@ typedef struct FFV1SliceContext { int slice_y; int run_index; +int slice_coding_mode; +int slice_rct_by_coef; +int slice_rct_ry_coef; PutBitContext pb; } FFV1SliceContext; @@ -130,9 +133,6 @@ typedef struct FFV1Context { int num_v_slices; int num_h_slices; int slice_reset_contexts; -int slice_coding_mode; -int slice_rct_by_coef; -int slice_rct_ry_coef; FFV1SliceContext *slices; } FFV1Context; diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index 6d3db25279..8464697fd3 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -240,11 +240,11 @@ static int decode_slice_header(const FFV1Context *f, FFV1Context *fs, if (fs->version > 3) { fs->slice_reset_contexts = get_rac(c, state); -fs->slice_coding_mode = get_symbol(c, state, 0); -if (fs->slice_coding_mode != 1) { -fs->slice_rct_by_coef = get_symbol(c, state, 0); -fs->slice_rct_ry_coef = get_symbol(c, state, 0); -if ((uint64_t)fs->slice_rct_by_coef + (uint64_t)fs->slice_rct_ry_coef > 4) { +sc->slice_coding_mode = get_symbol(c, state, 0); +if (sc->slice_coding_mode != 1) { +sc->slice_rct_by_coef = get_symbol(c, state, 0); +sc->slice_rct_ry_coef = get_symbol(c, state, 0); +if ((uint64_t)sc->slice_rct_by_coef + (uint64_t)sc->slice_rct_ry_coef > 4) { av_log(f->avctx, AV_LOG_ERROR, "slice_rct_y_coef out of range\n"); return AVERROR_INVALIDDATA; } @@ -294,8 +294,8 @@ static int decode_slice(AVCodecContext *c, void *arg) } } -fs->slice_rct_by_coef = 1; -fs->slice_rct_ry_coef = 1; +sc->slice_rct_by_coef = 1; +sc->slice_rct_ry_coef = 1; if (f->version > 2) { if (ff_ffv1_init_slice_state(f, fs) < 0) diff --git a/libavcodec/ffv1dec_template.c b/libavcodec/ffv1dec_template.c index 5c472168e2..dbcd4861ac 100644 --- a/libavcodec/ffv1dec_template.c +++ b/libavcodec/ffv1dec_template.c @@ -39,7 +39,7 @@ RENAME(decode_line)(FFV1Context *f, if (is_input_end(s, gb)) return AVERROR_INVALIDDATA; -if (s->slice_coding_mode == 1) { +if (sc->slice_coding_mode == 1) { int i; for (x = 0; x < w; x++) { int v = 0; @@ -162,10 +162,10 @@ static int RENAME(decode_rgb_frame)(FFV1Context *f, sample[p][1][-1]= sample[p][0][0 ]; sample[p][0][ w]= sample[p][0][w-1]; -if (lbd && s->slice_coding_mode == 0) +if (lbd && sc->slice_coding_mode == 0) ret = RENAME(decode_line)(f, s, sc, gb, w, sample[p], (p + 1)/2, 9); else -ret = RENAME(decode_line)(f, s, sc, gb, w, sample[p], (p + 1)/2, bits + (s->slice_coding_mode != 1)); +ret = RENAME(decode_line)(f, s, sc, gb, w, sample[p], (p + 1)/2, bits + (sc->slice_coding_mode != 1)); if (ret < 0) return ret; } @@ -175,10 +175,10 @@ static int RENAME(decode_rgb_frame)(FFV1Context *f, int r = sample[2][1][x]; int a = sample[3][1][x]; -if (s->slice_coding_mode != 1) { +if (sc->slice_coding_mode != 1) { b -= offset; r -= offset; -g -= (b * s->slice_rct_by_coef + r * s->slice_rct_ry_coef) >> 2; +g -= (b * sc->slice_rct_by_coef + r * sc->slice_rct_ry_coef) >> 2; b += g; r += g; } diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c index d334220e13..fb373b598b 100644 --- a/libavcodec/ffv1enc.c +++ b/libavcodec/ffv1enc.c @@ -926,13 +926,13 @@ static void encode_slice_header(FFV1Context *f, FFV1Context *fs, put_symbol(c, state, f->cur_enc_frame->sample_aspect_ratio.num, 0); put_symbol(c, state, f->cur_enc_frame->sample_aspect_ratio.den, 0); if (f->version > 3) { -put_rac(c, state, fs->slice_coding_mode == 1); -if (fs->slice_coding_mode == 1) +put_rac(c, state, sc->slice_coding_mode == 1); +if (sc->slice_coding_mode == 1) ff_ffv1_clear_slice_state(f, fs); -
[FFmpeg-cvslog] lavc/ffv1: drop redundant PlaneContext.quant_table
ffmpeg | branch: master | Anton Khirnov | Mon Jul 8 12:22:57 2024 +0200| [a411fc5a84367b679de38ad07adb0ef351ca35d8] | committer: Anton Khirnov lavc/ffv1: drop redundant PlaneContext.quant_table It is a copy of FFV1Context.quant_tables[quant_table_index]. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a411fc5a84367b679de38ad07adb0ef351ca35d8 --- libavcodec/ffv1.h | 1 - libavcodec/ffv1_template.c| 22 +++--- libavcodec/ffv1dec.c | 28 libavcodec/ffv1dec_template.c | 15 ++- libavcodec/ffv1enc.c | 24 libavcodec/ffv1enc_template.c | 13 - 6 files changed, 53 insertions(+), 50 deletions(-) diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h index 4d57172d5b..a87c2d2a36 100644 --- a/libavcodec/ffv1.h +++ b/libavcodec/ffv1.h @@ -59,7 +59,6 @@ typedef struct VlcState { } VlcState; typedef struct PlaneContext { -int16_t quant_table[MAX_CONTEXT_INPUTS][256]; int quant_table_index; int context_count; uint8_t (*state)[CONTEXT_SIZE]; diff --git a/libavcodec/ffv1_template.c b/libavcodec/ffv1_template.c index c5f61b0182..d15ad11021 100644 --- a/libavcodec/ffv1_template.c +++ b/libavcodec/ffv1_template.c @@ -29,25 +29,25 @@ static inline int RENAME(predict)(TYPE *src, TYPE *last) return mid_pred(L, L + T - LT, T); } -static inline int RENAME(get_context)(PlaneContext *p, TYPE *src, - TYPE *last, TYPE *last2) +static inline int RENAME(get_context)(const int16_t quant_table[MAX_CONTEXT_INPUTS][256], + TYPE *src, TYPE *last, TYPE *last2) { const int LT = last[-1]; const int T = last[0]; const int RT = last[1]; const int L = src[-1]; -if (p->quant_table[3][127] || p->quant_table[4][127]) { +if (quant_table[3][127] || quant_table[4][127]) { const int TT = last2[0]; const int LL = src[-2]; -return p->quant_table[0][(L - LT) & 0xFF] + - p->quant_table[1][(LT - T) & 0xFF] + - p->quant_table[2][(T - RT) & 0xFF] + - p->quant_table[3][(LL - L) & 0xFF] + - p->quant_table[4][(TT - T) & 0xFF]; +return quant_table[0][(L - LT) & 0xFF] + + quant_table[1][(LT - T) & 0xFF] + + quant_table[2][(T - RT) & 0xFF] + + quant_table[3][(LL - L) & 0xFF] + + quant_table[4][(TT - T) & 0xFF]; } else -return p->quant_table[0][(L - LT) & 0xFF] + - p->quant_table[1][(LT - T) & 0xFF] + - p->quant_table[2][(T - RT) & 0xFF]; +return quant_table[0][(L - LT) & 0xFF] + + quant_table[1][(LT - T) & 0xFF] + + quant_table[2][(T - RT) & 0xFF]; } diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index 66d9f63c1a..618020d10f 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -117,7 +117,8 @@ static int is_input_end(FFV1Context *s, GetBitContext *gb) #define RENAME(name) name ## 32 #include "ffv1dec_template.c" -static int decode_plane(FFV1Context *s, FFV1SliceContext *sc, +static int decode_plane(FFV1Context *f, +FFV1Context *s, FFV1SliceContext *sc, GetBitContext *gb, uint8_t *src, int w, int h, int stride, int plane_index, int pixel_stride) @@ -141,13 +142,13 @@ static int decode_plane(FFV1Context *s, FFV1SliceContext *sc, sample[0][w] = sample[0][w - 1]; if (s->avctx->bits_per_raw_sample <= 8) { -int ret = decode_line(s, sc, gb, w, sample, plane_index, 8); +int ret = decode_line(f, s, sc, gb, w, sample, plane_index, 8); if (ret < 0) return ret; for (x = 0; x < w; x++) src[x*pixel_stride + stride * y] = sample[1][x]; } else { -int ret = decode_line(s, sc, gb, w, sample, plane_index, s->avctx->bits_per_raw_sample); +int ret = decode_line(f, s, sc, gb, w, sample, plane_index, s->avctx->bits_per_raw_sample); if (ret < 0) return ret; if (s->packed_at_lsb) { @@ -207,7 +208,6 @@ static int decode_slice_header(const FFV1Context *f, FFV1Context *fs, return -1; } p->quant_table_index = idx; -memcpy(p->quant_table, f->quant_tables[idx], sizeof(p->quant_table)); context_count = f->context_count[idx]; if (p->context_count < context_count) { @@ -335,29 +335,29 @@ static int decode_slice(AVCodecContext *c, void *arg) const int chroma_height = AV_CEIL_RSHIFT(height, f->chroma_v_shift); const int cx= x >> f->chroma_h_shift; const int cy= y >> f->chroma_v_shift; -decode_plane(fs, sc, &gb, p->data[0] + ps*x + y*p->linesize[0], width, height, p->linesize[0]
[FFmpeg-cvslog] lavc/ffv1: always use the main context values of ac
ffmpeg | branch: master | Anton Khirnov | Mon Jul 8 13:11:52 2024 +0200| [9b86ba5a9289160962bca61df5639dae21784fb2] | committer: Anton Khirnov lavc/ffv1: always use the main context values of ac It cannot change between slices. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9b86ba5a9289160962bca61df5639dae21784fb2 --- libavcodec/ffv1.c | 6 +++--- libavcodec/ffv1dec.c | 19 +-- libavcodec/ffv1dec_template.c | 14 -- libavcodec/ffv1enc.c | 11 ++- libavcodec/ffv1enc_template.c | 12 +++- 5 files changed, 33 insertions(+), 29 deletions(-) diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c index 06a77c3a26..581e775ae2 100644 --- a/libavcodec/ffv1.c +++ b/libavcodec/ffv1.c @@ -59,7 +59,7 @@ av_cold int ff_ffv1_init_slice_state(const FFV1Context *f, FFV1Context *fs) for (j = 0; j < f->plane_count; j++) { PlaneContext *const p = &fs->plane[j]; -if (fs->ac != AC_GOLOMB_RICE) { +if (f->ac != AC_GOLOMB_RICE) { if (!p->state) p->state = av_malloc_array(p->context_count, CONTEXT_SIZE * sizeof(uint8_t)); @@ -78,7 +78,7 @@ av_cold int ff_ffv1_init_slice_state(const FFV1Context *f, FFV1Context *fs) } } -if (fs->ac == AC_RANGE_CUSTOM_TAB) { +if (f->ac == AC_RANGE_CUSTOM_TAB) { //FIXME only redo if state_transition changed for (j = 1; j < 256; j++) { fs->c. one_state[ j] = f->state_transition[j]; @@ -167,7 +167,7 @@ void ff_ffv1_clear_slice_state(const FFV1Context *f, FFV1Context *fs) for (i = 0; i < f->plane_count; i++) { PlaneContext *p = &fs->plane[i]; -if (fs->ac != AC_GOLOMB_RICE) { +if (f->ac != AC_GOLOMB_RICE) { if (f->initial_states[p->quant_table_index]) { memcpy(p->state, f->initial_states[p->quant_table_index], CONTEXT_SIZE * p->context_count); diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index 8464697fd3..992b6596ab 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -94,10 +94,9 @@ static inline int get_vlc_symbol(GetBitContext *gb, VlcState *const state, return ret; } -static int is_input_end(FFV1Context *s, GetBitContext *gb) +static int is_input_end(RangeCoder *c, GetBitContext *gb, int ac) { -if (s->ac != AC_GOLOMB_RICE) { -RangeCoder *const c = &s->c; +if (ac != AC_GOLOMB_RICE) { if (c->overread > MAX_OVERREAD) return AVERROR_INVALIDDATA; } else { @@ -123,6 +122,7 @@ static int decode_plane(FFV1Context *f, uint8_t *src, int w, int h, int stride, int plane_index, int pixel_stride) { +const int ac = f->ac; int x, y; int16_t *sample[2]; sample[0] = sc->sample_buffer + 3; @@ -142,13 +142,13 @@ static int decode_plane(FFV1Context *f, sample[0][w] = sample[0][w - 1]; if (s->avctx->bits_per_raw_sample <= 8) { -int ret = decode_line(f, s, sc, gb, w, sample, plane_index, 8); +int ret = decode_line(f, s, sc, gb, w, sample, plane_index, 8, ac); if (ret < 0) return ret; for (x = 0; x < w; x++) src[x*pixel_stride + stride * y] = sample[1][x]; } else { -int ret = decode_line(f, s, sc, gb, w, sample, plane_index, s->avctx->bits_per_raw_sample); +int ret = decode_line(f, s, sc, gb, w, sample, plane_index, s->avctx->bits_per_raw_sample, ac); if (ret < 0) return ret; if (s->packed_at_lsb) { @@ -197,7 +197,7 @@ static int decode_slice_header(const FFV1Context *f, FFV1Context *fs, av_assert0 ( (unsigned)sc->slice_x + (uint64_t)sc->slice_width <= f->width && (unsigned)sc->slice_y + (uint64_t)sc->slice_height <= f->height); -if (fs->ac == AC_GOLOMB_RICE && sc->slice_width >= (1<<23)) +if (f->ac == AC_GOLOMB_RICE && sc->slice_width >= (1<<23)) return AVERROR_INVALIDDATA; for (unsigned i = 0; i < f->plane_count; i++) { @@ -284,7 +284,7 @@ static int decode_slice(AVCodecContext *c, void *arg) pdst->state = NULL; pdst->vlc_state = NULL; -if (fssrc->ac) { +if (f->ac) { pdst->state = av_malloc_array(CONTEXT_SIZE, psrc->context_count); memcpy(pdst->state, psrc->state, CONTEXT_SIZE * psrc->context_count); } else { @@ -319,7 +319,7 @@ static int decode_slice(AVCodecContext *c, void *arg) x = sc->slice_x; y = sc->slice_y; -if (fs->ac == AC_GOLOMB_RICE) { +if (f->ac == AC_GOLOMB_RICE) { if (f->version == 3 && f->micro_version > 1 || f->version > 3) get_rac(&fs->c, (uint8_t[]) { 129 }); fs->ac_byte_count = f->version > 2 || (!x && !y) ? fs->c.bytestream - fs
[FFmpeg-cvslog] lavc/ffv1: move FFV1Context.plane to per-slice context
ffmpeg | branch: master | Anton Khirnov | Mon Jul 8 18:01:13 2024 +0200| [28769f6bc19ba10415405e63a06fe09f18d781b4] | committer: Anton Khirnov lavc/ffv1: move FFV1Context.plane to per-slice context > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=28769f6bc19ba10415405e63a06fe09f18d781b4 --- libavcodec/ffv1.c | 17 +++-- libavcodec/ffv1.h | 7 --- libavcodec/ffv1dec.c | 16 libavcodec/ffv1dec_template.c | 2 +- libavcodec/ffv1enc.c | 29 - libavcodec/ffv1enc_template.c | 2 +- 6 files changed, 37 insertions(+), 36 deletions(-) diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c index 581e775ae2..7bc4f1b135 100644 --- a/libavcodec/ffv1.c +++ b/libavcodec/ffv1.c @@ -52,12 +52,13 @@ av_cold int ff_ffv1_common_init(AVCodecContext *avctx) return 0; } -av_cold int ff_ffv1_init_slice_state(const FFV1Context *f, FFV1Context *fs) +av_cold int ff_ffv1_init_slice_state(const FFV1Context *f, + FFV1Context *fs, FFV1SliceContext *sc) { int j, i; for (j = 0; j < f->plane_count; j++) { -PlaneContext *const p = &fs->plane[j]; +PlaneContext *const p = &sc->plane[j]; if (f->ac != AC_GOLOMB_RICE) { if (!p->state) @@ -94,7 +95,7 @@ av_cold int ff_ffv1_init_slices_state(FFV1Context *f) int i, ret; for (i = 0; i < f->max_slice_count; i++) { FFV1Context *fs = f->slice_context[i]; -if ((ret = ff_ffv1_init_slice_state(f, fs)) < 0) +if ((ret = ff_ffv1_init_slice_state(f, fs, &f->slices[i])) < 0) return AVERROR(ENOMEM); } return 0; @@ -160,12 +161,12 @@ int ff_ffv1_allocate_initial_states(FFV1Context *f) return 0; } -void ff_ffv1_clear_slice_state(const FFV1Context *f, FFV1Context *fs) +void ff_ffv1_clear_slice_state(const FFV1Context *f, FFV1SliceContext *sc) { int i, j; for (i = 0; i < f->plane_count; i++) { -PlaneContext *p = &fs->plane[i]; +PlaneContext *p = &sc->plane[i]; if (f->ac != AC_GOLOMB_RICE) { if (f->initial_states[p->quant_table_index]) { @@ -191,17 +192,13 @@ av_cold int ff_ffv1_close(AVCodecContext *avctx) int i, j; for (j = 0; j < s->max_slice_count; j++) { -FFV1Context *fs = s->slice_context[j]; FFV1SliceContext *sc = &s->slices[j]; av_freep(&sc->sample_buffer); av_freep(&sc->sample_buffer32); -if (!fs) -continue; - for (i = 0; i < s->plane_count; i++) { -PlaneContext *p = &fs->plane[i]; +PlaneContext *p = &sc->plane[i]; av_freep(&p->state); av_freep(&p->vlc_state); diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h index e466aedbbe..68e59b300b 100644 --- a/libavcodec/ffv1.h +++ b/libavcodec/ffv1.h @@ -81,6 +81,7 @@ typedef struct FFV1SliceContext { int slice_rct_by_coef; int slice_rct_ry_coef; +PlaneContext plane[MAX_PLANES]; PutBitContext pb; } FFV1SliceContext; @@ -106,7 +107,6 @@ typedef struct FFV1Context { int plane_count; int ac; ///< 1=range coder <-> 0=golomb rice int ac_byte_count; ///< number of bytes used for AC coding -PlaneContext plane[MAX_PLANES]; int16_t quant_tables[MAX_QUANT_TABLES][MAX_CONTEXT_INPUTS][256]; int context_count[MAX_QUANT_TABLES]; uint8_t state_transition[256]; @@ -138,11 +138,12 @@ typedef struct FFV1Context { } FFV1Context; int ff_ffv1_common_init(AVCodecContext *avctx); -int ff_ffv1_init_slice_state(const FFV1Context *f, FFV1Context *fs); +int ff_ffv1_init_slice_state(const FFV1Context *f, FFV1Context *fs, + FFV1SliceContext *sc); int ff_ffv1_init_slices_state(FFV1Context *f); int ff_ffv1_init_slice_contexts(FFV1Context *f); int ff_ffv1_allocate_initial_states(FFV1Context *f); -void ff_ffv1_clear_slice_state(const FFV1Context *f, FFV1Context *fs); +void ff_ffv1_clear_slice_state(const FFV1Context *f, FFV1SliceContext *sc); int ff_ffv1_close(AVCodecContext *avctx); static av_always_inline int fold(int diff, int bits) diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index 992b6596ab..c46edbf940 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -201,7 +201,7 @@ static int decode_slice_header(const FFV1Context *f, FFV1Context *fs, return AVERROR_INVALIDDATA; for (unsigned i = 0; i < f->plane_count; i++) { -PlaneContext * const p = &fs->plane[i]; +PlaneContext * const p = &sc->plane[i]; int idx = get_symbol(c, state, 0); if (idx >= (unsigned)f->quant_table_count) { av_log(f->avctx, AV_LOG_ERROR, "quant_table_index out of range\n"); @@ -270,13 +270,14 @@ static int decode_slice(AVCodecContext *c, void *arg) if(f->fsrc && !(p->flags & AV_FRAME_FLAG_KEY)) { FFV1Context *fssrc = f->f
[FFmpeg-cvslog] lavc/ffv1: move RangeCoder to per-slice context
ffmpeg | branch: master | Anton Khirnov | Tue Jul 9 08:45:16 2024 +0200| [7b2bfba55db821dcb730624f34e9b62db35000ce] | committer: Anton Khirnov lavc/ffv1: move RangeCoder to per-slice context > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7b2bfba55db821dcb730624f34e9b62db35000ce --- libavcodec/ffv1.c | 9 +++-- libavcodec/ffv1.h | 5 ++- libavcodec/ffv1dec.c | 72 +++-- libavcodec/ffv1dec_template.c | 2 +- libavcodec/ffv1enc.c | 82 ++- libavcodec/ffv1enc_template.c | 2 +- 6 files changed, 87 insertions(+), 85 deletions(-) diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c index 7bc4f1b135..490baac233 100644 --- a/libavcodec/ffv1.c +++ b/libavcodec/ffv1.c @@ -53,7 +53,7 @@ av_cold int ff_ffv1_common_init(AVCodecContext *avctx) } av_cold int ff_ffv1_init_slice_state(const FFV1Context *f, - FFV1Context *fs, FFV1SliceContext *sc) + FFV1SliceContext *sc) { int j, i; @@ -82,8 +82,8 @@ av_cold int ff_ffv1_init_slice_state(const FFV1Context *f, if (f->ac == AC_RANGE_CUSTOM_TAB) { //FIXME only redo if state_transition changed for (j = 1; j < 256; j++) { -fs->c. one_state[ j] = f->state_transition[j]; -fs->c.zero_state[256 - j] = 256 - fs->c.one_state[j]; +sc->c. one_state[ j] = f->state_transition[j]; +sc->c.zero_state[256 - j] = 256 - sc->c.one_state[j]; } } @@ -94,8 +94,7 @@ av_cold int ff_ffv1_init_slices_state(FFV1Context *f) { int i, ret; for (i = 0; i < f->max_slice_count; i++) { -FFV1Context *fs = f->slice_context[i]; -if ((ret = ff_ffv1_init_slice_state(f, fs, &f->slices[i])) < 0) +if ((ret = ff_ffv1_init_slice_state(f, &f->slices[i])) < 0) return AVERROR(ENOMEM); } return 0; diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h index 68e59b300b..01c35dc942 100644 --- a/libavcodec/ffv1.h +++ b/libavcodec/ffv1.h @@ -83,12 +83,12 @@ typedef struct FFV1SliceContext { PlaneContext plane[MAX_PLANES]; PutBitContext pb; +RangeCoder c; } FFV1SliceContext; typedef struct FFV1Context { AVClass *class; AVCodecContext *avctx; -RangeCoder c; uint64_t rc_stat[256][2]; uint64_t (*rc_stat2[MAX_QUANT_TABLES])[32][2]; int version; @@ -138,8 +138,7 @@ typedef struct FFV1Context { } FFV1Context; int ff_ffv1_common_init(AVCodecContext *avctx); -int ff_ffv1_init_slice_state(const FFV1Context *f, FFV1Context *fs, - FFV1SliceContext *sc); +int ff_ffv1_init_slice_state(const FFV1Context *f, FFV1SliceContext *sc); int ff_ffv1_init_slices_state(FFV1Context *f); int ff_ffv1_init_slice_contexts(FFV1Context *f); int ff_ffv1_allocate_initial_states(FFV1Context *f); diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index c46edbf940..187359c9c6 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -168,7 +168,7 @@ static int decode_plane(FFV1Context *f, static int decode_slice_header(const FFV1Context *f, FFV1Context *fs, FFV1SliceContext *sc, AVFrame *frame) { -RangeCoder *c = &fs->c; +RangeCoder *c = &sc->c; uint8_t state[CONTEXT_SIZE]; unsigned ps, context_count; int sx, sy, sw, sh; @@ -299,7 +299,7 @@ static int decode_slice(AVCodecContext *c, void *arg) sc->slice_rct_ry_coef = 1; if (f->version > 2) { -if (ff_ffv1_init_slice_state(f, fs, sc) < 0) +if (ff_ffv1_init_slice_state(f, sc) < 0) return AVERROR(ENOMEM); if (decode_slice_header(f, fs, sc, p) < 0) { sc->slice_x = sc->slice_y = sc->slice_height = sc->slice_width = 0; @@ -307,7 +307,7 @@ static int decode_slice(AVCodecContext *c, void *arg) return AVERROR_INVALIDDATA; } } -if ((ret = ff_ffv1_init_slice_state(f, fs, sc)) < 0) +if ((ret = ff_ffv1_init_slice_state(f, sc)) < 0) return ret; if ((p->flags & AV_FRAME_FLAG_KEY) || fs->slice_reset_contexts) { ff_ffv1_clear_slice_state(f, sc); @@ -322,11 +322,11 @@ static int decode_slice(AVCodecContext *c, void *arg) if (f->ac == AC_GOLOMB_RICE) { if (f->version == 3 && f->micro_version > 1 || f->version > 3) -get_rac(&fs->c, (uint8_t[]) { 129 }); -fs->ac_byte_count = f->version > 2 || (!x && !y) ? fs->c.bytestream - fs->c.bytestream_start - 1 : 0; +get_rac(&sc->c, (uint8_t[]) { 129 }); +fs->ac_byte_count = f->version > 2 || (!x && !y) ? sc->c.bytestream - sc->c.bytestream_start - 1 : 0; init_get_bits(&gb, - fs->c.bytestream_start + fs->ac_byte_count, - (fs->c.bytestream_end - fs->c.bytestream_start - fs->ac_byte_count) * 8); + sc->c.bytestream_start + fs->ac_byte_co
[FFmpeg-cvslog] lavc/ffv1enc: store per-slice rc_stat(2?) in FFV1SliceContext
ffmpeg | branch: master | Anton Khirnov | Wed Jul 10 16:51:45 2024 +0200| [e7d0f44138a7b7303ccc760d28d608893dbf7641] | committer: Anton Khirnov lavc/ffv1enc: store per-slice rc_stat(2?) in FFV1SliceContext Instead of the per-slice FFV1Context, which will be removed in future commits. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e7d0f44138a7b7303ccc760d28d608893dbf7641 --- libavcodec/ffv1.c | 6 ++ libavcodec/ffv1.h | 3 +++ libavcodec/ffv1enc.c | 20 ++-- libavcodec/ffv1enc_template.c | 4 ++-- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c index 490baac233..4ef04f6b9b 100644 --- a/libavcodec/ffv1.c +++ b/libavcodec/ffv1.c @@ -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]); } diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h index 01c35dc942..bee7b75614 100644 --- a/libavcodec/ffv1.h +++ b/libavcodec/ffv1.h @@ -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 { diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c index 6790366149..a17fdd35ec 100644 --- a/libavcodec/ffv1enc.c +++ b/libavcodec/ffv1enc.c @@ -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]; } } } diff --git a/libavcodec/ffv1enc_template.c b/libavcodec/ffv1enc_template.c index 1339b2bd4c..24dcf2a68e 100644 --- a/libavcodec/ffv1enc_template.c +++ b/libavcodec/ffv1enc_template.c @@ -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); } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] lavc/ffv1: move ac_byte_count to per-slice context
ffmpeg | branch: master | Anton Khirnov | Wed Jul 10 17:20:07 2024 +0200| [96e8af6c4d031313e42a5dfb5caf2bcab48bf976] | committer: Anton Khirnov lavc/ffv1: move ac_byte_count to per-slice context > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=96e8af6c4d031313e42a5dfb5caf2bcab48bf976 --- libavcodec/ffv1.h| 2 +- libavcodec/ffv1dec.c | 6 +++--- libavcodec/ffv1enc.c | 9 - 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h index bee7b75614..ae81940073 100644 --- a/libavcodec/ffv1.h +++ b/libavcodec/ffv1.h @@ -85,6 +85,7 @@ typedef struct FFV1SliceContext { PutBitContext pb; RangeCoder c; +int ac_byte_count; ///< number of bytes used for AC coding uint64_t rc_stat[256][2]; uint64_t (*rc_stat2[MAX_QUANT_TABLES])[32][2]; } FFV1SliceContext; @@ -109,7 +110,6 @@ typedef struct FFV1Context { const AVFrame *cur_enc_frame; int plane_count; int ac; ///< 1=range coder <-> 0=golomb rice -int ac_byte_count; ///< number of bytes used for AC coding int16_t quant_tables[MAX_QUANT_TABLES][MAX_CONTEXT_INPUTS][256]; int context_count[MAX_QUANT_TABLES]; uint8_t state_transition[256]; diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index 187359c9c6..d171660c85 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -323,10 +323,10 @@ static int decode_slice(AVCodecContext *c, void *arg) if (f->ac == AC_GOLOMB_RICE) { if (f->version == 3 && f->micro_version > 1 || f->version > 3) get_rac(&sc->c, (uint8_t[]) { 129 }); -fs->ac_byte_count = f->version > 2 || (!x && !y) ? sc->c.bytestream - sc->c.bytestream_start - 1 : 0; +sc->ac_byte_count = f->version > 2 || (!x && !y) ? sc->c.bytestream - sc->c.bytestream_start - 1 : 0; init_get_bits(&gb, - sc->c.bytestream_start + fs->ac_byte_count, - (sc->c.bytestream_end - sc->c.bytestream_start - fs->ac_byte_count) * 8); + sc->c.bytestream_start + sc->ac_byte_count, + (sc->c.bytestream_end - sc->c.bytestream_start - sc->ac_byte_count) * 8); } av_assert1(width && height); diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c index a17fdd35ec..b861210462 100644 --- a/libavcodec/ffv1enc.c +++ b/libavcodec/ffv1enc.c @@ -1060,10 +1060,10 @@ retry: encode_slice_header(f, fs, sc); } if (f->ac == AC_GOLOMB_RICE) { -fs->ac_byte_count = f->version > 2 || (!x && !y) ? ff_rac_terminate(&sc->c, f->version > 2) : 0; +sc->ac_byte_count = f->version > 2 || (!x && !y) ? ff_rac_terminate(&sc->c, f->version > 2) : 0; init_put_bits(&sc->pb, - sc->c.bytestream_start + fs->ac_byte_count, - sc->c.bytestream_end - sc->c.bytestream_start - fs->ac_byte_count); + sc->c.bytestream_start + sc->ac_byte_count, + sc->c.bytestream_end - sc->c.bytestream_start - sc->ac_byte_count); } if (f->colorspace == 0 && c->pix_fmt != AV_PIX_FMT_YA8) { @@ -1212,7 +1212,6 @@ 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; @@ -1220,7 +1219,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, bytes = ff_rac_terminate(&sc->c, 1); } else { flush_put_bits(&sc->pb); // FIXME: nicer padding -bytes = fs->ac_byte_count + put_bytes_output(&sc->pb); +bytes = sc->ac_byte_count + put_bytes_output(&sc->pb); } if (i > 0 || f->version > 2) { av_assert0(bytes < pkt->size / f->slice_count); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavc/ffv1enc: stop using per-slice FFV1Context
ffmpeg | branch: master | Anton Khirnov | Wed Jul 10 17:25:54 2024 +0200| [84dda322020584e249840bc815591429c75fe5d0] | committer: Anton Khirnov lavc/ffv1enc: stop using per-slice FFV1Context All remaining accesses to them are for fields that have the same value in the main encoder context. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=84dda322020584e249840bc815591429c75fe5d0 --- libavcodec/ffv1enc.c | 55 --- libavcodec/ffv1enc_template.c | 29 --- 2 files changed, 41 insertions(+), 43 deletions(-) diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c index b861210462..23d757e5c6 100644 --- a/libavcodec/ffv1enc.c +++ b/libavcodec/ffv1enc.c @@ -269,14 +269,14 @@ static inline void put_vlc_symbol(PutBitContext *pb, VlcState *const state, #define RENAME(name) name ## 32 #include "ffv1enc_template.c" -static int encode_plane(FFV1Context *f, -FFV1Context *s, FFV1SliceContext *sc, +static int encode_plane(FFV1Context *f, FFV1SliceContext *sc, const uint8_t *src, int w, int h, int stride, int plane_index, int pixel_stride) { int x, y, i, ret; const int ac = f->ac; -const int ring_size = s->context_model ? 3 : 2; +const int pass1 = !!(f->avctx->flags & AV_CODEC_FLAG_PASS1); +const int ring_size = f->context_model ? 3 : 2; int16_t *sample[3]; sc->run_index = 0; @@ -288,22 +288,22 @@ static int encode_plane(FFV1Context *f, sample[0][-1]= sample[1][0 ]; sample[1][ w]= sample[1][w-1]; -if (s->bits_per_raw_sample <= 8) { +if (f->bits_per_raw_sample <= 8) { for (x = 0; x < w; x++) sample[0][x] = src[x * pixel_stride + stride * y]; -if((ret = encode_line(f, s, sc, w, sample, plane_index, 8, ac)) < 0) +if((ret = encode_line(f, sc, f->avctx, w, sample, plane_index, 8, ac, pass1)) < 0) return ret; } else { -if (s->packed_at_lsb) { +if (f->packed_at_lsb) { for (x = 0; x < w; x++) { sample[0][x] = ((uint16_t*)(src + stride*y))[x]; } } else { for (x = 0; x < w; x++) { -sample[0][x] = ((uint16_t*)(src + stride*y))[x] >> (16 - s->bits_per_raw_sample); +sample[0][x] = ((uint16_t*)(src + stride*y))[x] >> (16 - f->bits_per_raw_sample); } } -if((ret = encode_line(f, s, sc, w, sample, plane_index, s->bits_per_raw_sample, ac)) < 0) +if((ret = encode_line(f, sc, f->avctx, w, sample, plane_index, f->bits_per_raw_sample, ac, pass1)) < 0) return ret; } } @@ -909,8 +909,7 @@ slices_ok: return 0; } -static void encode_slice_header(FFV1Context *f, FFV1Context *fs, -FFV1SliceContext *sc) +static void encode_slice_header(FFV1Context *f, FFV1SliceContext *sc) { RangeCoder *c = &sc->c; uint8_t state[CONTEXT_SIZE]; @@ -943,7 +942,7 @@ static void encode_slice_header(FFV1Context *f, FFV1Context *fs, } } -static void choose_rct_params(FFV1Context *fs, FFV1SliceContext *sc, +static void choose_rct_params(const FFV1Context *f, FFV1SliceContext *sc, const uint8_t *src[3], const int stride[3], int w, int h) { #define NB_Y_COEFF 15 @@ -969,7 +968,7 @@ static void choose_rct_params(FFV1Context *fs, FFV1SliceContext *sc, int stat[NB_Y_COEFF] = {0}; int x, y, i, p, best; int16_t *sample[3]; -int lbd = fs->bits_per_raw_sample <= 8; +int lbd = f->bits_per_raw_sample <= 8; for (y = 0; y < h; y++) { int lastr=0, lastg=0, lastb=0; @@ -1028,10 +1027,8 @@ static void choose_rct_params(FFV1Context *fs, FFV1SliceContext *sc, static int encode_slice(AVCodecContext *c, void *arg) { -FFV1Context *fs = *(void **)arg; -FFV1Context *f = fs->avctx->priv_data; -const int si = (FFV1Context**)arg - f->slice_context; -FFV1SliceContext *sc = &f->slices[si]; +FFV1SliceContext *sc = arg; +FFV1Context *f = c->priv_data; int width= sc->slice_width; int height = sc->slice_height; int x= sc->slice_x; @@ -1047,7 +1044,7 @@ static int encode_slice(AVCodecContext *c, void *arg) sc->slice_coding_mode = 0; if (f->version > 3) { -choose_rct_params(fs, sc, planes, p->linesize, width, height); +choose_rct_params(f, sc, planes, p->linesize, width, height); } else { sc->slice_rct_by_coef = 1; sc->slice_rct_ry_coef = 1; @@ -1057,7 +1054,7 @@ retry: if (f->key_frame) ff_ffv1_clear_slice_state(f, sc); if (f->version > 2) { -encode_slice_header(f, fs, sc); +encode_slice_header(f, sc); } if (f->ac == AC_GOLOMB_RICE) { sc->ac_byte
[FFmpeg-cvslog] lavc/ffv1dec: move slice_reset_contexts to per-slice context
ffmpeg | branch: master | Anton Khirnov | Wed Jul 10 17:38:24 2024 +0200| [f2aeba56c45ad83b2a776effccfbb622525a3ca8] | committer: Anton Khirnov lavc/ffv1dec: move slice_reset_contexts to per-slice context > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f2aeba56c45ad83b2a776effccfbb622525a3ca8 --- libavcodec/ffv1.h| 16 +--- libavcodec/ffv1dec.c | 4 ++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h index ae81940073..cef61f38ec 100644 --- a/libavcodec/ffv1.h +++ b/libavcodec/ffv1.h @@ -86,8 +86,19 @@ typedef struct FFV1SliceContext { RangeCoder c; int ac_byte_count; ///< number of bytes used for AC coding -uint64_t rc_stat[256][2]; -uint64_t (*rc_stat2[MAX_QUANT_TABLES])[32][2]; + +union { +// decoder-only +struct { +int slice_reset_contexts; +}; + +// encoder-only +struct { +uint64_t rc_stat[256][2]; +uint64_t (*rc_stat2[MAX_QUANT_TABLES])[32][2]; +}; +}; } FFV1SliceContext; typedef struct FFV1Context { @@ -135,7 +146,6 @@ typedef struct FFV1Context { int max_slice_count; int num_v_slices; int num_h_slices; -int slice_reset_contexts; FFV1SliceContext *slices; } FFV1Context; diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index d171660c85..ddcbe1583e 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -239,7 +239,7 @@ static int decode_slice_header(const FFV1Context *f, FFV1Context *fs, } if (fs->version > 3) { -fs->slice_reset_contexts = get_rac(c, state); +sc->slice_reset_contexts = get_rac(c, state); sc->slice_coding_mode = get_symbol(c, state, 0); if (sc->slice_coding_mode != 1) { sc->slice_rct_by_coef = get_symbol(c, state, 0); @@ -309,7 +309,7 @@ static int decode_slice(AVCodecContext *c, void *arg) } if ((ret = ff_ffv1_init_slice_state(f, sc)) < 0) return ret; -if ((p->flags & AV_FRAME_FLAG_KEY) || fs->slice_reset_contexts) { +if ((p->flags & AV_FRAME_FLAG_KEY) || sc->slice_reset_contexts) { ff_ffv1_clear_slice_state(f, sc); } else if (fs->slice_damaged) { return AVERROR_INVALIDDATA; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavc/ffv1dec: stop using per-slice FFV1Context
ffmpeg | branch: master | Anton Khirnov | Wed Jul 10 17:25:54 2024 +0200| [d44812f7cf8994ccaf7ccf309c958876688dcf79] | committer: Anton Khirnov lavc/ffv1dec: stop using per-slice FFV1Context All remaining accesses to them are for fields that have the same value in the main encoder context. Drop now-unused FFV1Context.slice_contexts. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d44812f7cf8994ccaf7ccf309c958876688dcf79 --- libavcodec/ffv1.c | 18 --- libavcodec/ffv1.h | 1 - libavcodec/ffv1dec.c | 54 ++- libavcodec/ffv1dec_template.c | 16 ++--- 4 files changed, 33 insertions(+), 56 deletions(-) diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c index 4ef04f6b9b..07cf5564cc 100644 --- a/libavcodec/ffv1.c +++ b/libavcodec/ffv1.c @@ -102,7 +102,7 @@ av_cold int ff_ffv1_init_slices_state(FFV1Context *f) av_cold int ff_ffv1_init_slice_contexts(FFV1Context *f) { -int i, max_slice_count = f->num_h_slices * f->num_v_slices; +int max_slice_count = f->num_h_slices * f->num_v_slices; av_assert0(max_slice_count > 0); @@ -112,7 +112,7 @@ av_cold int ff_ffv1_init_slice_contexts(FFV1Context *f) f->max_slice_count = max_slice_count; -for (i = 0; i < max_slice_count;) { +for (int i = 0; i < max_slice_count; i++) { FFV1SliceContext *sc = &f->slices[i]; int sx = i % f->num_h_slices; int sy = i / f->num_h_slices; @@ -120,22 +120,15 @@ av_cold int ff_ffv1_init_slice_contexts(FFV1Context *f) int sxe = f->avctx->width * (sx + 1) / f->num_h_slices; int sys = f->avctx->height * sy / f->num_v_slices; int sye = f->avctx->height * (sy + 1) / f->num_v_slices; -FFV1Context *fs = av_mallocz(sizeof(*fs)); - -if (!fs) -return AVERROR(ENOMEM); - -f->slice_context[i++] = fs; -memcpy(fs, f, sizeof(*fs)); sc->slice_width = sxe - sxs; sc->slice_height = sye - sys; sc->slice_x = sxs; sc->slice_y = sys; -sc->sample_buffer = av_malloc_array((fs->width + 6), 3 * MAX_PLANES * +sc->sample_buffer = av_malloc_array((f->width + 6), 3 * MAX_PLANES * sizeof(*sc->sample_buffer)); -sc->sample_buffer32 = av_malloc_array((fs->width + 6), 3 * MAX_PLANES * +sc->sample_buffer32 = av_malloc_array((f->width + 6), 3 * MAX_PLANES * sizeof(*sc->sample_buffer32)); if (!sc->sample_buffer || !sc->sample_buffer32) return AVERROR(ENOMEM); @@ -213,9 +206,6 @@ av_cold int ff_ffv1_close(AVCodecContext *avctx) av_freep(&s->rc_stat2[j]); } -for (i = 0; i < s->max_slice_count; i++) -av_freep(&s->slice_context[i]); - av_freep(&s->slices); return 0; diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h index c4803654f2..9d79219921 100644 --- a/libavcodec/ffv1.h +++ b/libavcodec/ffv1.h @@ -141,7 +141,6 @@ typedef struct FFV1Context { int gob_count; int quant_table_count; -struct FFV1Context *slice_context[MAX_SLICES]; int slice_count; int max_slice_count; int num_v_slices; diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index 3d529ff4e9..1933efbfbc 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -116,8 +116,7 @@ static int is_input_end(RangeCoder *c, GetBitContext *gb, int ac) #define RENAME(name) name ## 32 #include "ffv1dec_template.c" -static int decode_plane(FFV1Context *f, -FFV1Context *s, FFV1SliceContext *sc, +static int decode_plane(FFV1Context *f, FFV1SliceContext *sc, GetBitContext *gb, uint8_t *src, int w, int h, int stride, int plane_index, int pixel_stride) @@ -141,23 +140,23 @@ static int decode_plane(FFV1Context *f, sample[1][-1] = sample[0][0]; sample[0][w] = sample[0][w - 1]; -if (s->avctx->bits_per_raw_sample <= 8) { -int ret = decode_line(f, s, sc, gb, w, sample, plane_index, 8, ac); +if (f->avctx->bits_per_raw_sample <= 8) { +int ret = decode_line(f, sc, gb, w, sample, plane_index, 8, ac); if (ret < 0) return ret; for (x = 0; x < w; x++) src[x*pixel_stride + stride * y] = sample[1][x]; } else { -int ret = decode_line(f, s, sc, gb, w, sample, plane_index, s->avctx->bits_per_raw_sample, ac); +int ret = decode_line(f, sc, gb, w, sample, plane_index, f->avctx->bits_per_raw_sample, ac); if (ret < 0) return ret; -if (s->packed_at_lsb) { +if (f->packed_at_lsb) { for (x = 0; x < w; x++) { ((uint16_t*)(src + stride*y))[x*pixel_stride] = s
[FFmpeg-cvslog] lavc/ffv1dec: inline copy_fields() into update_thread_context()
ffmpeg | branch: master | Anton Khirnov | Wed Jul 10 20:18:24 2024 +0200| [c335218a818484071718576722dd654d3f02c558] | committer: Anton Khirnov lavc/ffv1dec: inline copy_fields() into update_thread_context() It is now only called from a single place, so there is no point in it being a separate function. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c335218a818484071718576722dd654d3f02c558 --- libavcodec/ffv1dec.c | 38 -- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index 1933efbfbc..b2c7503ad8 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -1022,27 +1022,6 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe, } #if HAVE_THREADS -static void copy_fields(FFV1Context *fsdst, const FFV1Context *fssrc, -const FFV1Context *fsrc) -{ -fsdst->version = fsrc->version; -fsdst->micro_version = fsrc->micro_version; -fsdst->chroma_planes = fsrc->chroma_planes; -fsdst->chroma_h_shift = fsrc->chroma_h_shift; -fsdst->chroma_v_shift = fsrc->chroma_v_shift; -fsdst->transparency= fsrc->transparency; -fsdst->plane_count = fsrc->plane_count; -fsdst->ac = fsrc->ac; -fsdst->colorspace = fsrc->colorspace; - -fsdst->ec = fsrc->ec; -fsdst->intra = fsrc->intra; -fsdst->key_frame_ok= fsrc->key_frame_ok; - -fsdst->packed_at_lsb = fsrc->packed_at_lsb; -fsdst->slice_count = fsrc->slice_count; -} - static int update_thread_context(AVCodecContext *dst, const AVCodecContext *src) { FFV1Context *fsrc = src->priv_data; @@ -1051,7 +1030,22 @@ static int update_thread_context(AVCodecContext *dst, const AVCodecContext *src) if (dst == src) return 0; -copy_fields(fdst, fsrc, fsrc); +fdst->version = fsrc->version; +fdst->micro_version = fsrc->micro_version; +fdst->chroma_planes = fsrc->chroma_planes; +fdst->chroma_h_shift = fsrc->chroma_h_shift; +fdst->chroma_v_shift = fsrc->chroma_v_shift; +fdst->transparency= fsrc->transparency; +fdst->plane_count = fsrc->plane_count; +fdst->ac = fsrc->ac; +fdst->colorspace = fsrc->colorspace; + +fdst->ec = fsrc->ec; +fdst->intra = fsrc->intra; +fdst->key_frame_ok= fsrc->key_frame_ok; + +fdst->packed_at_lsb = fsrc->packed_at_lsb; +fdst->slice_count = fsrc->slice_count; fdst->use32bit = fsrc->use32bit; memcpy(fdst->state_transition, fsrc->state_transition, sizeof(fdst->state_transition)); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavc/ffv1dec: move slice_damaged to per-slice context
ffmpeg | branch: master | Anton Khirnov | Wed Jul 10 17:38:24 2024 +0200| [2b21cdff6ebf8e65b0ff08a6e591a13236c00e37] | committer: Anton Khirnov lavc/ffv1dec: move slice_damaged to per-slice context > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2b21cdff6ebf8e65b0ff08a6e591a13236c00e37 --- libavcodec/ffv1.h| 2 +- libavcodec/ffv1dec.c | 18 -- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h index cef61f38ec..c4803654f2 100644 --- a/libavcodec/ffv1.h +++ b/libavcodec/ffv1.h @@ -91,6 +91,7 @@ typedef struct FFV1SliceContext { // decoder-only struct { int slice_reset_contexts; +int slice_damaged; }; // encoder-only @@ -131,7 +132,6 @@ typedef struct FFV1Context { int ec; int intra; -int slice_damaged; int key_frame_ok; int context_model; diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index ddcbe1583e..3d529ff4e9 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -269,11 +269,10 @@ static int decode_slice(AVCodecContext *c, void *arg) ff_progress_frame_await(&f->last_picture, si); if(f->fsrc && !(p->flags & AV_FRAME_FLAG_KEY)) { -FFV1Context *fssrc = f->fsrc->slice_context[si]; const FFV1SliceContext *scsrc = &f->fsrc->slices[si]; if (!(p->flags & AV_FRAME_FLAG_KEY)) -fs->slice_damaged |= fssrc->slice_damaged; +sc->slice_damaged |= scsrc->slice_damaged; for (int i = 0; i < f->plane_count; i++) { const PlaneContext *psrc = &scsrc->plane[i]; @@ -303,7 +302,7 @@ static int decode_slice(AVCodecContext *c, void *arg) return AVERROR(ENOMEM); if (decode_slice_header(f, fs, sc, p) < 0) { sc->slice_x = sc->slice_y = sc->slice_height = sc->slice_width = 0; -fs->slice_damaged = 1; +sc->slice_damaged = 1; return AVERROR_INVALIDDATA; } } @@ -311,7 +310,7 @@ static int decode_slice(AVCodecContext *c, void *arg) return ret; if ((p->flags & AV_FRAME_FLAG_KEY) || sc->slice_reset_contexts) { ff_ffv1_clear_slice_state(f, sc); -} else if (fs->slice_damaged) { +} else if (sc->slice_damaged) { return AVERROR_INVALIDDATA; } @@ -365,7 +364,7 @@ static int decode_slice(AVCodecContext *c, void *arg) v = sc->c.bytestream_end - sc->c.bytestream - 2 - 5*f->ec; if (v) { av_log(f->avctx, AV_LOG_ERROR, "bytestream end mismatching by %d\n", v); -fs->slice_damaged = 1; +sc->slice_damaged = 1; } } @@ -794,7 +793,7 @@ static int read_header(FFV1Context *f) FFV1SliceContext *sc = &f->slices[j]; fs->packed_at_lsb = f->packed_at_lsb; -fs->slice_damaged = 0; +sc->slice_damaged = 0; if (f->version == 2) { int sx = get_symbol(c, state, 0); @@ -966,7 +965,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe, } else { av_log(f->avctx, AV_LOG_ERROR, "\n"); } -fs->slice_damaged = 1; +sc->slice_damaged = 1; } if (avctx->debug & FF_DEBUG_PICT_INFO) { av_log(avctx, AV_LOG_DEBUG, "slice %d, CRC: 0x%08"PRIX32"\n", i, AV_RB32(buf_p + v - 4)); @@ -990,9 +989,8 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe, sizeof(void*)); for (int i = f->slice_count - 1; i >= 0; i--) { -FFV1Context *fs = f->slice_context[i]; FFV1SliceContext *sc = &f->slices[i]; -if (fs->slice_damaged && f->last_picture.f) { +if (sc->slice_damaged && f->last_picture.f) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt); const uint8_t *src[4]; uint8_t *dst[4]; @@ -1045,7 +1043,6 @@ static void copy_fields(FFV1Context *fsdst, const FFV1Context *fssrc, fsdst->ec = fsrc->ec; fsdst->intra = fsrc->intra; -fsdst->slice_damaged = fssrc->slice_damaged; fsdst->key_frame_ok= fsrc->key_frame_ok; fsdst->packed_at_lsb = fsrc->packed_at_lsb; @@ -1078,6 +1075,7 @@ static int update_thread_context(AVCodecContext *dst, const AVCodecContext *src) const FFV1SliceContext *sc0 = &fsrc->slices[i]; copy_fields(fsdst, fssrc, fsrc); +sc->slice_damaged = sc0->slice_damaged; if (fsrc->version < 3) { sc->slice_x = sc0->slice_x; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavc/ffv1: change FFV1SliceContext.plane into a RefStruct object
ffmpeg | branch: master | Anton Khirnov | Thu Jul 11 11:08:55 2024 +0200| [bcf08c11710cab5db8eb3d0774e1a93e322fb821] | committer: Anton Khirnov lavc/ffv1: change FFV1SliceContext.plane into a RefStruct object Frame threading in the FFV1 decoder works in a very unusual way - the state that needs to be propagated from the previous frame is not decoded pixels(¹), but each slice's entropy coder state after decoding the slice. For that purpose, the decoder's update_thread_context() callback stores a pointer to the previous frame thread's private data. Then, when decoding each slice, the frame thread uses the standard progress mechanism to wait for the corresponding slice in the previous frame to be completed, then copies the entropy coder state from the previously-stored pointer. This approach is highly dubious, as update_thread_context() should be the only point where frame-thread contexts come into direct contact. There are no guarantees that the stored pointer will be valid at all, or will contain any particular data after update_thread_context() finishes. More specifically, this code can break due to the fact that keyframes reset entropy coder state and thus do not need to wait for the previous frame. As an example, consider a decoder process with 2 frame threads - thread 0 with its context 0, and thread 1 with context 1 - decoding a previous frame P, current frame F, followed by a keyframe K. Then consider concurrent execution consistent with the following sequence of events: * thread 0 starts decoding P * thread 0 reads P's slice header, then calls ff_thread_finish_setup() allowing next frame thread to start * main thread calls update_thread_context() to transfer state from context 0 to context 1; context 1 stores a pointer to context 0's private data * thread 1 starts decoding F * thread 1 reads F's slice header, then calls ff_thread_finish_setup() allowing the next frame thread to start decoding * thread 0 finishes decoding P * thread 0 starts decoding K; since K is a keyframe, it does not wait for F and reallocates the arrays holding entropy coder state * thread 0 finishes decoding K * thread 1 reads entropy coder state from its stored pointer to context 0, however it finds state from K rather than from P This execution is currently prevented by special-casing FFV1 in the generic frame threading code, however that is supremely ugly. It also involves unnecessary copies of the state arrays, when in fact they can only be used by one thread at a time. This commit addresses these deficiencies by changing the array of PlaneContext (each of which contains the allocated state arrays) embedded in FFV1SliceContext into a RefStruct object. This object can then be propagated across frame threads in standard manner. Since the code structure guarantees only one thread accesses it at a time, no copies are necessary. It is also re-created for keyframes, solving the above issue cleanly. Special-casing of FFV1 in the generic frame threading code will be removed in a later commit. (¹) except in the case of a damaged slice, when previous frame's pixels are used directly > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bcf08c11710cab5db8eb3d0774e1a93e322fb821 --- libavcodec/ffv1.c| 30 -- libavcodec/ffv1.h| 4 +++- libavcodec/ffv1dec.c | 33 + 3 files changed, 36 insertions(+), 31 deletions(-) diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c index 07cf5564cc..9c219b5ddb 100644 --- a/libavcodec/ffv1.c +++ b/libavcodec/ffv1.c @@ -31,6 +31,7 @@ #include "avcodec.h" #include "ffv1.h" +#include "refstruct.h" av_cold int ff_ffv1_common_init(AVCodecContext *avctx) { @@ -52,6 +53,24 @@ av_cold int ff_ffv1_common_init(AVCodecContext *avctx) return 0; } +static void planes_free(FFRefStructOpaque opaque, void *obj) +{ +PlaneContext *planes = obj; + +for (int i = 0; i < MAX_PLANES; i++) { +PlaneContext *p = &planes[i]; + +av_freep(&p->state); +av_freep(&p->vlc_state); +} +} + +PlaneContext* ff_ffv1_planes_alloc(void) +{ +return ff_refstruct_alloc_ext(sizeof(PlaneContext) * MAX_PLANES, + 0, NULL, planes_free); +} + av_cold int ff_ffv1_init_slice_state(const FFV1Context *f, FFV1SliceContext *sc) { @@ -132,6 +151,10 @@ av_cold int ff_ffv1_init_slice_contexts(FFV1Context *f) sizeof(*sc->sample_buffer32)); if (!sc->sample_buffer || !sc->sample_buffer32) return AVERROR(ENOMEM); + +sc->plane = ff_ffv1_planes_alloc(); +if (!sc->plane) +return AVERROR(ENOMEM); } return 0; @@ -188,12 +211,7 @@ av_cold int ff_ffv1_close(AVCodecContext *avctx) av_freep(&sc->sample_buffer); av_freep(&sc->sample_buffer32); -for (i = 0; i < s->plane_count; i++) { -PlaneContext *p
[FFmpeg-cvslog] avutil/hwcontext_videotoolbox: Fix build with older SDKs
ffmpeg | branch: master | Marvin Scholz | Tue Jul 23 11:10:44 2024 +0200| [ca7fcf50891997eb95b4bf6d5cd4e2446e8c8631] | committer: Zhao Zhili avutil/hwcontext_videotoolbox: Fix build with older SDKs The previous fix was not sufficient. To make things easier to reason about, split the function and add the guards there instead of complicating the call site more. Signed-off-by: Zhao Zhili > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ca7fcf50891997eb95b4bf6d5cd4e2446e8c8631 --- libavutil/hwcontext_videotoolbox.c | 51 +- 1 file changed, 39 insertions(+), 12 deletions(-) diff --git a/libavutil/hwcontext_videotoolbox.c b/libavutil/hwcontext_videotoolbox.c index ab7556936d..1794459943 100644 --- a/libavutil/hwcontext_videotoolbox.c +++ b/libavutil/hwcontext_videotoolbox.c @@ -532,6 +532,37 @@ CFStringRef av_map_videotoolbox_color_trc_from_av(enum AVColorTransferCharacteri } } +/** + * Copy all attachments for the specified mode from the given buffer. + */ +static CFDictionaryRef vt_cv_buffer_copy_attachments(CVBufferRef buffer, + CVAttachmentMode attachment_mode) +{ +CFDictionaryRef dict; + +// Check that our SDK is at least macOS 12 / iOS 15 / tvOS 15 +#if (TARGET_OS_OSX && defined(__MAC_12_0)&& __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_12_0) || \ +(TARGET_OS_IOS && defined(__IPHONE_15_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_15_0) || \ +(TARGET_OS_TV && defined(__TVOS_15_0) && __TV_OS_VERSION_MAX_ALLOWED >= __TVOS_15_0) +// On recent enough versions, just use the respective API +if (__builtin_available(macOS 12.0, iOS 15.0, tvOS 15.0, *)) +return CVBufferCopyAttachments(buffer, attachment_mode); +#endif + +// Check that the target is lower than macOS 12 / iOS 15 / tvOS 15 +// else this would generate a deprecation warning and anyway never run because +// the runtime availability check above would be always true. +#if (TARGET_OS_OSX && (!defined(__MAC_12_0)|| __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_12_0)) || \ +(TARGET_OS_IOS && (!defined(__IPHONE_15_0) || __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_15_0)) || \ +(TARGET_OS_TV && (!defined(__TVOS_15_0) || __TV_OS_VERSION_MIN_REQUIRED < __TVOS_15_0)) +// Fallback on SDKs or runtime versions < macOS 12 / iOS 15 / tvOS 15 +dict = CVBufferGetAttachments(buffer, attachment_mode); +return (dict) ? CFDictionaryCreateCopy(NULL, dict) : NULL; +#else +return NULL; // Impossible, just make the compiler happy +#endif +} + static int vt_pixbuf_set_colorspace(void *log_ctx, CVPixelBufferRef pixbuf, const AVFrame *src) { @@ -591,24 +622,20 @@ static int vt_pixbuf_set_colorspace(void *log_ctx, #if (TARGET_OS_OSX && __MAC_OS_X_VERSION_MAX_ALLOWED >= 100800) || \ (TARGET_OS_IOS && __IPHONE_OS_VERSION_MAX_ALLOWED >= 10) if (__builtin_available(macOS 10.8, iOS 10, *)) { -CFDictionaryRef attachments = NULL; -if (__builtin_available(macOS 12.0, iOS 15.0, *)) -attachments = CVBufferCopyAttachments(pixbuf, kCVAttachmentMode_ShouldPropagate); -#if (TARGET_OS_OSX && __MAC_OS_X_VERSION_MIN_REQUIRED <= 12) || \ -(TARGET_OS_IOS && __IPHONE_OS_VERSION_MIN_REQUIRED <= 15) -else { -CFDictionaryRef tmp = CVBufferGetAttachments(pixbuf, kCVAttachmentMode_ShouldPropagate); -if (tmp) -attachments = CFDictionaryCreateCopy(NULL, tmp); -} -#endif +CFDictionaryRef attachments = +vt_cv_buffer_copy_attachments(pixbuf, kCVAttachmentMode_ShouldPropagate); + if (attachments) { -colorspace = CVImageBufferCreateColorSpaceFromAttachments(attachments); +colorspace = +CVImageBufferCreateColorSpaceFromAttachments(attachments); CFRelease(attachments); } } #endif +// Done outside the above preprocessor code and if's so that +// in any case a wrong kCVImageBufferCGColorSpaceKey is removed +// if the above code is not used or fails. if (colorspace) { CVBufferSetAttachment(pixbuf, kCVImageBufferCGColorSpaceKey, colorspace, kCVAttachmentMode_ShouldPropagate); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avutil/hwcontext_vaapi: use the correct type for VASurfaceAttribExternalBuffers.buffers
ffmpeg | branch: master | James Almer | Wed Jul 31 10:00:54 2024 -0300| [6f8e365a2af2b6b21701d41eed3b2e3f8a436eeb] | committer: James Almer avutil/hwcontext_vaapi: use the correct type for VASurfaceAttribExternalBuffers.buffers Should fix ticket #5. Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6f8e365a2af2b6b21701d41eed3b2e3f8a436eeb --- libavutil/hwcontext_vaapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c index 4cb25dd032..15fd84aa40 100644 --- a/libavutil/hwcontext_vaapi.c +++ b/libavutil/hwcontext_vaapi.c @@ -1225,7 +1225,7 @@ static int vaapi_map_from_drm(AVHWFramesContext *src_fc, AVFrame *dst, if (!use_prime2 || vas != VA_STATUS_SUCCESS) { int k; -unsigned long buffer_handle; +uintptr_t buffer_handle; VASurfaceAttribExternalBuffers buffer_desc; VASurfaceAttrib buffer_attrs[2] = { { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/aacps_tablegen_template: don't redefine CONFIG_HARDCODED_TABLES
ffmpeg | branch: master | James Almer | Wed Jul 31 11:35:03 2024 -0300| [f4daf633b2e31e2e0fb3e0fcf1c7deacbc57b93e] | committer: James Almer avcodec/aacps_tablegen_template: don't redefine CONFIG_HARDCODED_TABLES Fixes relevant warnings when compiling with --enable-hardcoded-tables Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f4daf633b2e31e2e0fb3e0fcf1c7deacbc57b93e --- libavcodec/aacps_tablegen_template.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/aacps_tablegen_template.c b/libavcodec/aacps_tablegen_template.c index e70edf884b..e05887b9b1 100644 --- a/libavcodec/aacps_tablegen_template.c +++ b/libavcodec/aacps_tablegen_template.c @@ -22,6 +22,8 @@ #include #define BUILD_TABLES +#include "config.h" +#undef CONFIG_HARDCODED_TABLES #define CONFIG_HARDCODED_TABLES 0 #include "aac_defines.h" ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avutil/hwcontext_vaapi: use the correct type for VASurfaceAttribExternalBuffers.buffers
ffmpeg | branch: release/7.0 | James Almer | Wed Jul 31 10:00:54 2024 -0300| [b6b55f6e2be6839faca6067aafe7d3800f2f6ea4] | committer: James Almer avutil/hwcontext_vaapi: use the correct type for VASurfaceAttribExternalBuffers.buffers Should fix ticket #5. Signed-off-by: James Almer (cherry picked from commit 6f8e365a2af2b6b21701d41eed3b2e3f8a436eeb) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b6b55f6e2be6839faca6067aafe7d3800f2f6ea4 --- libavutil/hwcontext_vaapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c index 56d03aa4cd..95a68e62c5 100644 --- a/libavutil/hwcontext_vaapi.c +++ b/libavutil/hwcontext_vaapi.c @@ -1213,7 +1213,7 @@ static int vaapi_map_from_drm(AVHWFramesContext *src_fc, AVFrame *dst, if (!use_prime2 || vas != VA_STATUS_SUCCESS) { int k; -unsigned long buffer_handle; +uintptr_t buffer_handle; VASurfaceAttribExternalBuffers buffer_desc; VASurfaceAttrib buffer_attrs[2] = { { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/aacps_tablegen_template: don't redefine CONFIG_HARDCODED_TABLES
ffmpeg | branch: release/7.0 | James Almer | Wed Jul 31 11:35:03 2024 -0300| [d0d740946b72bbe736e99254a0bf921598a000d0] | committer: James Almer avcodec/aacps_tablegen_template: don't redefine CONFIG_HARDCODED_TABLES Fixes relevant warnings when compiling with --enable-hardcoded-tables Signed-off-by: James Almer (cherry picked from commit f4daf633b2e31e2e0fb3e0fcf1c7deacbc57b93e) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d0d740946b72bbe736e99254a0bf921598a000d0 --- libavcodec/aacps_tablegen_template.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/aacps_tablegen_template.c b/libavcodec/aacps_tablegen_template.c index e70edf884b..e05887b9b1 100644 --- a/libavcodec/aacps_tablegen_template.c +++ b/libavcodec/aacps_tablegen_template.c @@ -22,6 +22,8 @@ #include #define BUILD_TABLES +#include "config.h" +#undef CONFIG_HARDCODED_TABLES #define CONFIG_HARDCODED_TABLES 0 #include "aac_defines.h" ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavc/bswapdsp: add RV Zvbb bswap16 and bswap32
ffmpeg | branch: master | Rémi Denis-Courmont | Sun Jul 28 21:17:58 2024 +0300| [952b426f3bcc6206eff2fa338ff7da475a28692b] | committer: Rémi Denis-Courmont lavc/bswapdsp: add RV Zvbb bswap16 and bswap32 > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=952b426f3bcc6206eff2fa338ff7da475a28692b --- libavcodec/riscv/Makefile| 1 + libavcodec/riscv/bswapdsp_init.c | 13 +++--- libavcodec/riscv/bswapdsp_rvvb.S | 52 3 files changed, 63 insertions(+), 3 deletions(-) diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile index 1491b6c067..58666e1d35 100644 --- a/libavcodec/riscv/Makefile +++ b/libavcodec/riscv/Makefile @@ -16,6 +16,7 @@ RVV-OBJS-$(CONFIG_BLOCKDSP) += riscv/blockdsp_rvv.o OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_init.o RV-OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_rvb.o RVV-OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_rvv.o +RVVB-OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_rvvb.o OBJS-$(CONFIG_EXR_DECODER) += riscv/exrdsp_init.o RVV-OBJS-$(CONFIG_EXR_DECODER) += riscv/exrdsp_rvv.o OBJS-$(CONFIG_FLAC_DECODER) += riscv/flacdsp_init.o diff --git a/libavcodec/riscv/bswapdsp_init.c b/libavcodec/riscv/bswapdsp_init.c index c13387c232..43d74a4e98 100644 --- a/libavcodec/riscv/bswapdsp_init.c +++ b/libavcodec/riscv/bswapdsp_init.c @@ -27,6 +27,8 @@ void ff_bswap32_buf_rvb(uint32_t *dst, const uint32_t *src, int len); void ff_bswap16_buf_rvv(uint16_t *dst, const uint16_t *src, int len); +void ff_bswap32_buf_rvvb(uint32_t *dst, const uint32_t *src, int len); +void ff_bswap16_buf_rvvb(uint16_t *dst, const uint16_t *src, int len); av_cold void ff_bswapdsp_init_riscv(BswapDSPContext *c) { @@ -38,9 +40,14 @@ av_cold void ff_bswapdsp_init_riscv(BswapDSPContext *c) c->bswap_buf = ff_bswap32_buf_rvb; #endif #if HAVE_RVV -if (flags & AV_CPU_FLAG_RVB_ADDR) { -if (flags & AV_CPU_FLAG_RVV_I32) -c->bswap16_buf = ff_bswap16_buf_rvv; +if ((flags & AV_CPU_FLAG_RVV_I32) && (flags & AV_CPU_FLAG_RVB)) { +c->bswap16_buf = ff_bswap16_buf_rvv; +#if HAVE_RV_ZVBB +if (flags & AV_CPU_FLAG_RV_ZVBB) { +c->bswap_buf = ff_bswap32_buf_rvvb; +c->bswap16_buf = ff_bswap16_buf_rvvb; +} +#endif } #endif #endif diff --git a/libavcodec/riscv/bswapdsp_rvvb.S b/libavcodec/riscv/bswapdsp_rvvb.S new file mode 100644 index 00..165ac104a9 --- /dev/null +++ b/libavcodec/riscv/bswapdsp_rvvb.S @@ -0,0 +1,52 @@ +/* + * Copyright © 2024 Rémi Denis-Courmont. + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" +#include "libavutil/riscv/asm.S" + +func ff_bswap32_buf_rvvb, zve32x, zvbb, zba +lpad0 +1: +vsetvli t0, a2, e32, m8, ta, ma +vle32.v v8, (a1) +sub a2, a2, t0 +vrev8.v v8, v8 +sh2add a1, t0, a1 +vse32.v v8, (a0) +sh2add a0, t0, a0 +bneza2, 1b + +ret +endfunc + +func ff_bswap16_buf_rvvb, zve32x, zvbb, zba +lpad0 +1: +vsetvli t0, a2, e16, m8, ta, ma +vle16.v v8, (a1) +sub a2, a2, t0 +vrev8.v v8, v8 +sh1add a1, t0, a1 +vse16.v v8, (a0) +sh1add a0, t0, a0 +bneza2, 1b + +ret +endfunc ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavc/pixblockdsp: specialise aligned 16-bit get_pixels
ffmpeg | branch: master | Rémi Denis-Courmont | Thu Jul 25 18:38:32 2024 +0300| [d527d238728bf9b75d55960c4279134d0fba493b] | committer: Rémi Denis-Courmont lavc/pixblockdsp: specialise aligned 16-bit get_pixels The current code assumes that we have unaligned rows, which hurts on platforms with slower unaligned accesses. (Also, this lets the compiler unroll manually, which it seems to do in practice.) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d527d238728bf9b75d55960c4279134d0fba493b --- libavcodec/pixblockdsp.c | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libavcodec/pixblockdsp.c b/libavcodec/pixblockdsp.c index bbbeca1618..1fff244511 100644 --- a/libavcodec/pixblockdsp.c +++ b/libavcodec/pixblockdsp.c @@ -26,6 +26,13 @@ static void get_pixels_16_c(int16_t *restrict block, const uint8_t *pixels, ptrdiff_t stride) +{ +for (int i = 0; i < 8; i++) +AV_COPY128(block + i * 8, pixels + i * stride); +} + +static void get_pixels_unaligned_16_c(int16_t *restrict block, + const uint8_t *pixels, ptrdiff_t stride) { AV_COPY128U(block + 0 * 8, pixels + 0 * stride); AV_COPY128U(block + 1 * 8, pixels + 1 * stride); @@ -90,7 +97,7 @@ av_cold void ff_pixblockdsp_init(PixblockDSPContext *c, AVCodecContext *avctx) case 10: case 12: case 14: -c->get_pixels_unaligned = +c->get_pixels_unaligned = get_pixels_unaligned_16_c; c->get_pixels = get_pixels_16_c; break; default: ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavc/rv34dsp: use saturating add/sub for R-V V DC add
ffmpeg | branch: master | Rémi Denis-Courmont | Sun Jul 28 21:40:52 2024 +0300| [54ae270213b5a98f923bfd4506e450b2e764ede2] | committer: Rémi Denis-Courmont lavc/rv34dsp: use saturating add/sub for R-V V DC add T-Head C908 (cycles): rv34_idct_dc_add_c: 113.2 rv34_idct_dc_add_rvv_i32: 48.5 (before) rv34_idct_dc_add_rvv_i32: 39.5 (after) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=54ae270213b5a98f923bfd4506e450b2e764ede2 --- libavcodec/riscv/rv34dsp_rvv.S | 19 +++ 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/libavcodec/riscv/rv34dsp_rvv.S b/libavcodec/riscv/rv34dsp_rvv.S index 478bc0a860..fc0ffec4fe 100644 --- a/libavcodec/riscv/rv34dsp_rvv.S +++ b/libavcodec/riscv/rv34dsp_rvv.S @@ -41,14 +41,17 @@ func ff_rv34_idct_dc_add_rvv, zve32x mul t1, t1, a2 addi t1, t1, 512 srai t1, t1, 10 -vsetivli zero, 4*4, e16, m2, ta, ma -vzext.vf2 v2, v0 -vadd.vx v2, v2, t1 -vmax.vx v2, v2, zero -vsetvli zero, zero, e8, m1, ta, ma -vnclipu.wiv0, v2, 0 -vsetivli zero, 4, e8, mf4, ta, ma -vsse32.v v0, (a0), a1 +vsetivlizero, 4*4, e8, m2, ta, ma +bgezt1, 1f +neg t1, t1 +vssubu.vx v0, v0, t1 +vsetivlizero, 4, e8, mf4, ta, ma +vsse32.vv0, (a0), a1 +ret +1: +vsaddu.vx v0, v0, t1 +vsetivlizero, 4, e8, mf4, ta, ma +vsse32.vv0, (a0), a1 ret endfunc ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavu/riscv: fix return type
ffmpeg | branch: master | Rémi Denis-Courmont | Wed Jul 31 17:45:28 2024 +0300| [54b1970c60743eb1ce971d66c6b6230a36040687] | committer: Rémi Denis-Courmont lavu/riscv: fix return type > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=54b1970c60743eb1ce971d66c6b6230a36040687 --- libavutil/riscv/intmath.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavutil/riscv/intmath.h b/libavutil/riscv/intmath.h index 24f165eef1..a09248f903 100644 --- a/libavutil/riscv/intmath.h +++ b/libavutil/riscv/intmath.h @@ -84,8 +84,8 @@ static av_always_inline av_const float av_clipf_rvf(float a, float min, #if defined (__riscv_d) || defined (__riscv_zdinx) #define av_clipd av_clipd_rvd -static av_always_inline av_const float av_clipd_rvd(double a, double min, -double max) +static av_always_inline av_const double av_clipd_rvd(double a, double min, + double max) { return fmin(fmax(a, min), max); } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] checkasm/riscv: preserve T1 whilst calling...
ffmpeg | branch: master | Rémi Denis-Courmont | Mon Jul 29 22:33:16 2024 +0300| [656a9664bf828fc19b1e5a6e982bbcad456d1092] | committer: Rémi Denis-Courmont checkasm/riscv: preserve T1 whilst calling... This preserves T1 whilst calling the instrumented function. In a Sci-Fi setting where type-based Control Flow Integrity (CFI) is supported, the calling code (i.e., the `checkasm` test case) will set T1 to the expected value of the landing pad label (LPL) of the instrumented function. The call wrapper will always use LPL zero which is a wild card. We should preserve the value of T1 at least until the indirect call to the instrumented function. Of course this is Sci-Fi, because: 1) there is no hardware (or even QEMU) support yet, 2) all our assembler functions currently use LPL zero anyway. This uses T3 rather than T2 because indirect branches with T2 is reserved for notionally direct calls made with an indirect call instruction (e.g. due to GOT indirection), and are exempted from forward-edge CFI checks. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=656a9664bf828fc19b1e5a6e982bbcad456d1092 --- tests/checkasm/riscv/checkasm.S | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/checkasm/riscv/checkasm.S b/tests/checkasm/riscv/checkasm.S index e8bcbb271e..c4b034ae23 100644 --- a/tests/checkasm/riscv/checkasm.S +++ b/tests/checkasm/riscv/checkasm.S @@ -89,8 +89,8 @@ func checkasm_get_wrapper, v /* Clobber the vector configuration */ li t0, 0/* Vector length: zero */ -li t1, -1 << 31 /* Vector type: illegal */ -vsetvl zero, t0, t1 +li t2, -4 /* Vector type: illegal */ +vsetvl zero, t0, t2 csrwi vxrm, 3 /* Rounding mode: round-to-odd */ csrwi vxsat, 1 /* Saturation:encountered */ @@ -120,7 +120,7 @@ func checkasm_get_wrapper, v /* Clobber the saved and temporary registers */ .irpn, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 -.if (\n > 0 && \n < 7) +.if (\n > 1 && \n < 7) mv t\n, t0 .endif fmv.d.x ft\n, t0 @@ -131,9 +131,9 @@ func checkasm_get_wrapper, v /* Call the tested function */ la.tls.ie t0, checked_func add t0, tp, t0 -ld t1, (t0) +ld t3, (t0) sd zero, (t0) -jalrt1 +jalrt3 /* Check special register values */ la.tls.ie t0, saved_regs ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavc/audiodsp: properly unroll vector_clipf
ffmpeg | branch: master | Rémi Denis-Courmont | Thu Jul 25 22:40:25 2024 +0300| [d86b6767ce98fda133e2b8f7f954a497eab2e528] | committer: Rémi Denis-Courmont lavc/audiodsp: properly unroll vector_clipf Given that source and destination can alias, the compiler was forced to perform each read-modify-write sequentially. We cannot use the `restrict` qualifier to avoid this here because the AC-3 encoder uses the function in-place. Instead this commit provides an explicit guarantee to the compiler that batches of 8 elements will not overlap, so that it can interleave calculations. In practice contemporary optimising compilers are able to unroll and keep the temporary array in FPU registers (without spilling). On SiFive-U74, this speeds the same signs branch by 4x, and the opposite signs branch 1.5x. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d86b6767ce98fda133e2b8f7f954a497eab2e528 --- libavcodec/audiodsp.c | 40 +--- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/libavcodec/audiodsp.c b/libavcodec/audiodsp.c index c5427d3535..9e83f06aaa 100644 --- a/libavcodec/audiodsp.c +++ b/libavcodec/audiodsp.c @@ -38,41 +38,35 @@ static inline float clipf_c_one(float a, uint32_t mini, static void vector_clipf_c_opposite_sign(float *dst, const float *src, float min, float max, int len) { -int i; uint32_t mini= av_float2int(min); uint32_t maxi= av_float2int(max); uint32_t maxisign= maxi ^ (1U << 31); -for (i = 0; i < len; i += 8) { -dst[i + 0] = clipf_c_one(src[i + 0], mini, maxi, maxisign); -dst[i + 1] = clipf_c_one(src[i + 1], mini, maxi, maxisign); -dst[i + 2] = clipf_c_one(src[i + 2], mini, maxi, maxisign); -dst[i + 3] = clipf_c_one(src[i + 3], mini, maxi, maxisign); -dst[i + 4] = clipf_c_one(src[i + 4], mini, maxi, maxisign); -dst[i + 5] = clipf_c_one(src[i + 5], mini, maxi, maxisign); -dst[i + 6] = clipf_c_one(src[i + 6], mini, maxi, maxisign); -dst[i + 7] = clipf_c_one(src[i + 7], mini, maxi, maxisign); +for (int i = 0; i < len; i += 8) { +float tmp[8]; + +for (int j = 0; j < 8; j++) +tmp[j]= clipf_c_one(src[i + j], mini, maxi, maxisign); +for (int j = 0; j < 8; j++) +dst[i + j] = tmp[j]; } } static void vector_clipf_c(float *dst, const float *src, int len, float min, float max) { -int i; - if (min < 0 && max > 0) { vector_clipf_c_opposite_sign(dst, src, min, max, len); -} else { -for (i = 0; i < len; i += 8) { -dst[i] = av_clipf(src[i], min, max); -dst[i + 1] = av_clipf(src[i + 1], min, max); -dst[i + 2] = av_clipf(src[i + 2], min, max); -dst[i + 3] = av_clipf(src[i + 3], min, max); -dst[i + 4] = av_clipf(src[i + 4], min, max); -dst[i + 5] = av_clipf(src[i + 5], min, max); -dst[i + 6] = av_clipf(src[i + 6], min, max); -dst[i + 7] = av_clipf(src[i + 7], min, max); -} +return; +} + +for (int i = 0; i < len; i += 8) { +float tmp[8]; + +for (int j = 0; j < 8; j++) +tmp[j]= av_clipf(src[i + j], min, max); +for (int j = 0; j < 8; j++) +dst[i + j] = tmp[j]; } } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavc/audiodsp: drop opposite sign optimisation
ffmpeg | branch: master | Rémi Denis-Courmont | Thu Jul 25 22:50:35 2024 +0300| [c48213b2dc0b6329359a84e0d332e4697d84ea90] | committer: Rémi Denis-Courmont lavc/audiodsp: drop opposite sign optimisation This was added along side the original SSE(one) DSP function in 0a68cd876e14f76a00df7bb8edbfeb350f8ef617 without rationale. This was presumably faster on x87, which is no longer relevant since we pretty much assume SSE2 or later on x86. Meanwhile this function is ~2.5x slower than the normal floating point one on SiFive-U74. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c48213b2dc0b6329359a84e0d332e4697d84ea90 --- libavcodec/audiodsp.c | 35 --- 1 file changed, 35 deletions(-) diff --git a/libavcodec/audiodsp.c b/libavcodec/audiodsp.c index 9e83f06aaa..fd6a00345f 100644 --- a/libavcodec/audiodsp.c +++ b/libavcodec/audiodsp.c @@ -22,44 +22,9 @@ #include "libavutil/common.h" #include "audiodsp.h" -static inline float clipf_c_one(float a, uint32_t mini, -uint32_t maxi, uint32_t maxisign) -{ -uint32_t ai = av_float2int(a); - -if (ai > mini) -return av_int2float(mini); -else if ((ai ^ (1U << 31)) > maxisign) -return av_int2float(maxi); -else -return a; -} - -static void vector_clipf_c_opposite_sign(float *dst, const float *src, - float min, float max, int len) -{ -uint32_t mini= av_float2int(min); -uint32_t maxi= av_float2int(max); -uint32_t maxisign= maxi ^ (1U << 31); - -for (int i = 0; i < len; i += 8) { -float tmp[8]; - -for (int j = 0; j < 8; j++) -tmp[j]= clipf_c_one(src[i + j], mini, maxi, maxisign); -for (int j = 0; j < 8; j++) -dst[i + j] = tmp[j]; -} -} - static void vector_clipf_c(float *dst, const float *src, int len, float min, float max) { -if (min < 0 && max > 0) { -vector_clipf_c_opposite_sign(dst, src, min, max, len); -return; -} - for (int i = 0; i < len; i += 8) { float tmp[8]; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavc/audiodsp: drop R-V F vector_clipf
ffmpeg | branch: master | Rémi Denis-Courmont | Thu Jul 25 22:58:55 2024 +0300| [2f083fd5817f99e9874acf4fd04e6b4a7c47bb86] | committer: Rémi Denis-Courmont lavc/audiodsp: drop R-V F vector_clipf This is now firmly slower than C. SiFive-U74 (cycles): audiodsp.vector_clipf_c: 31.2 audiodsp.vector_clipf_rvf: 39.5 > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2f083fd5817f99e9874acf4fd04e6b4a7c47bb86 --- libavcodec/riscv/Makefile| 1 - libavcodec/riscv/audiodsp_init.c | 8 +-- libavcodec/riscv/audiodsp_rvf.S | 50 3 files changed, 1 insertion(+), 58 deletions(-) diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile index 58666e1d35..b3a6b588c9 100644 --- a/libavcodec/riscv/Makefile +++ b/libavcodec/riscv/Makefile @@ -9,7 +9,6 @@ RVVB-OBJS-$(CONFIG_AC3DSP) += riscv/ac3dsp_rvvb.o OBJS-$(CONFIG_ALAC_DECODER) += riscv/alacdsp_init.o RVV-OBJS-$(CONFIG_ALAC_DECODER) += riscv/alacdsp_rvv.o OBJS-$(CONFIG_AUDIODSP) += riscv/audiodsp_init.o -RV-OBJS-$(CONFIG_AUDIODSP) += riscv/audiodsp_rvf.o RVV-OBJS-$(CONFIG_AUDIODSP) += riscv/audiodsp_rvv.o OBJS-$(CONFIG_BLOCKDSP) += riscv/blockdsp_init.o RVV-OBJS-$(CONFIG_BLOCKDSP) += riscv/blockdsp_rvv.o diff --git a/libavcodec/riscv/audiodsp_init.c b/libavcodec/riscv/audiodsp_init.c index f606406429..5750d4d8a7 100644 --- a/libavcodec/riscv/audiodsp_init.c +++ b/libavcodec/riscv/audiodsp_init.c @@ -24,8 +24,6 @@ #include "libavutil/cpu.h" #include "libavcodec/audiodsp.h" -void ff_vector_clipf_rvf(float *dst, const float *src, int len, float min, float max); - int32_t ff_scalarproduct_int16_rvv(const int16_t *v1, const int16_t *v2, int len); void ff_vector_clip_int32_rvv(int32_t *dst, const int32_t *src, int32_t min, int32_t max, unsigned int len); @@ -33,12 +31,9 @@ void ff_vector_clipf_rvv(float *dst, const float *src, int len, float min, float av_cold void ff_audiodsp_init_riscv(AudioDSPContext *c) { -#if HAVE_RV +#if HAVE_RVV int flags = av_get_cpu_flags(); -if (flags & AV_CPU_FLAG_RVF) -c->vector_clipf = ff_vector_clipf_rvf; -#if HAVE_RVV if (flags & AV_CPU_FLAG_RVB_ADDR) { if (flags & AV_CPU_FLAG_RVV_I32) { c->scalarproduct_int16 = ff_scalarproduct_int16_rvv; @@ -48,5 +43,4 @@ av_cold void ff_audiodsp_init_riscv(AudioDSPContext *c) c->vector_clipf = ff_vector_clipf_rvv; } #endif -#endif } diff --git a/libavcodec/riscv/audiodsp_rvf.S b/libavcodec/riscv/audiodsp_rvf.S deleted file mode 100644 index 97aa930ab5..00 --- a/libavcodec/riscv/audiodsp_rvf.S +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright © 2022 Rémi Denis-Courmont. - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "libavutil/riscv/asm.S" - -func ff_vector_clipf_rvf, f -lpad0 -NOHWF fmv.w.x fa0, a3 -NOHWF fmv.w.x fa1, a4 -1: -flw ft0, (a1) -flw ft1, 4(a1) -fmax.s ft0, ft0, fa0 -flw ft2, 8(a1) -fmax.s ft1, ft1, fa0 -flw ft3, 12(a1) -fmax.s ft2, ft2, fa0 -addia2, a2, -4 -fmax.s ft3, ft3, fa0 -addia1, a1, 16 -fmin.s ft0, ft0, fa1 -fmin.s ft1, ft1, fa1 -fsw ft0, (a0) -fmin.s ft2, ft2, fa1 -fsw ft1, 4(a0) -fmin.s ft3, ft3, fa1 -fsw ft2, 8(a0) -fsw ft3, 12(a0) -addia0, a0, 16 -bneza2, 1b - -ret -endfunc ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavc/riscv: drop probing for F & D extensions
ffmpeg | branch: master | Rémi Denis-Courmont | Thu Jul 25 23:20:05 2024 +0300| [1b2a925e94c772c59a88c03c1654bddf6aff0ca2] | committer: Rémi Denis-Courmont lavc/riscv: drop probing for F & D extensions F and D extensions are included in all RISC-V application profiles ever made (so starting from RV64GC a.k.a. RVA20). Realistically they need to be selected at compilation time. Currently, there are no consumers for these two flags. If there is ever a need to reintroduce F- or D-specific optimisations, we can always use __riscv_f or __riscv_d compiler predefined macros respectively. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1b2a925e94c772c59a88c03c1654bddf6aff0ca2 --- libavutil/cpu.c | 2 -- libavutil/riscv/cpu.c | 12 libavutil/tests/cpu.c | 2 -- tests/checkasm/checkasm.c | 2 -- 4 files changed, 18 deletions(-) diff --git a/libavutil/cpu.c b/libavutil/cpu.c index 17afe8858a..6c26182b78 100644 --- a/libavutil/cpu.c +++ b/libavutil/cpu.c @@ -184,8 +184,6 @@ int av_parse_cpu_caps(unsigned *flags, const char *s) { "lasx", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_LASX },.unit = "flags" }, #elif ARCH_RISCV { "rvi", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVI },.unit = "flags" }, -{ "rvf", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVF },.unit = "flags" }, -{ "rvd", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVD },.unit = "flags" }, { "rvb", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVB },.unit = "flags" }, { "zve32x", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVV_I32 },.unit = "flags" }, { "zve32f", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVV_F32 },.unit = "flags" }, diff --git a/libavutil/riscv/cpu.c b/libavutil/riscv/cpu.c index e035f4b024..6537e91965 100644 --- a/libavutil/riscv/cpu.c +++ b/libavutil/riscv/cpu.c @@ -58,8 +58,6 @@ int ff_get_cpu_flags_riscv(void) if (__riscv_hwprobe(pairs, FF_ARRAY_ELEMS(pairs), 0, NULL, 0) == 0) { if (pairs[0].value & RISCV_HWPROBE_BASE_BEHAVIOR_IMA) ret |= AV_CPU_FLAG_RVI; -if (pairs[1].value & RISCV_HWPROBE_IMA_FD) -ret |= AV_CPU_FLAG_RVF | AV_CPU_FLAG_RVD; #ifdef RISCV_HWPROBE_IMA_V if (pairs[1].value & RISCV_HWPROBE_IMA_V) ret |= AV_CPU_FLAG_RVV_I32 | AV_CPU_FLAG_RVV_I64 @@ -96,10 +94,6 @@ int ff_get_cpu_flags_riscv(void) if (hwcap & HWCAP_RV('I')) ret |= AV_CPU_FLAG_RVI; -if (hwcap & HWCAP_RV('F')) -ret |= AV_CPU_FLAG_RVF; -if (hwcap & HWCAP_RV('D')) -ret |= AV_CPU_FLAG_RVD; if (hwcap & HWCAP_RV('B')) ret |= AV_CPU_FLAG_RVB_ADDR | AV_CPU_FLAG_RVB_BASIC | AV_CPU_FLAG_RVB; @@ -114,12 +108,6 @@ int ff_get_cpu_flags_riscv(void) #ifdef __riscv_i ret |= AV_CPU_FLAG_RVI; #endif -#if defined (__riscv_flen) && (__riscv_flen >= 32) -ret |= AV_CPU_FLAG_RVF; -#if (__riscv_flen >= 64) -ret |= AV_CPU_FLAG_RVD; -#endif -#endif #ifdef __riscv_zba ret |= AV_CPU_FLAG_RVB_ADDR; diff --git a/libavutil/tests/cpu.c b/libavutil/tests/cpu.c index b4b11775d8..e03fbf94eb 100644 --- a/libavutil/tests/cpu.c +++ b/libavutil/tests/cpu.c @@ -86,8 +86,6 @@ static const struct { { AV_CPU_FLAG_LASX, "lasx" }, #elif ARCH_RISCV { AV_CPU_FLAG_RVI, "rvi"}, -{ AV_CPU_FLAG_RVF, "rvf"}, -{ AV_CPU_FLAG_RVD, "rvd"}, { AV_CPU_FLAG_RVB_ADDR, "zba"}, { AV_CPU_FLAG_RVB_BASIC, "zbb"}, { AV_CPU_FLAG_RVB, "rvb"}, diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index 016f2329b0..49b47f8615 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -291,8 +291,6 @@ static const struct { #elif ARCH_RISCV { "RVI", "rvi", AV_CPU_FLAG_RVI }, { "misaligned", "misaligned", AV_CPU_FLAG_RV_MISALIGNED }, -{ "RVF", "rvf", AV_CPU_FLAG_RVF }, -{ "RVD", "rvd", AV_CPU_FLAG_RVD }, { "RVBaddr", "rvb_a",AV_CPU_FLAG_RVB_ADDR }, { "RVBbasic", "rvb_b",AV_CPU_FLAG_RVB_BASIC }, { "RVB", "rvb", AV_CPU_FLAG_RVB }, ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/utils: apply the same alignment to YUV410 as we do to YUV420 for snow
ffmpeg | branch: release/6.1 | Michael Niedermayer | Mon Jun 17 13:31:02 2024 +0200| [b169821e8f68e685a0164ff2146c1a0c7f93d1a7] | committer: Michael Niedermayer avcodec/utils: apply the same alignment to YUV410 as we do to YUV420 for snow The snow encoder uses block based motion estimation which can read out of array if insufficient alignment is used It may be better to only apply this for the encoder, as it would safe a few bytes of memory for the decoder. Until then, this fixes the issue in a simple way. Fixes: out of array access Fixes: 68963/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SNOW_fuzzer-4979988435632128 Fixes: 68969/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SNOW_fuzzer-6239933667803136.fuzz Fixed: 70497/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SNOW_fuzzer-5751882631413760 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer (cherry picked from commit 58fbeb59e74ac9a4ca81e9bc44141abcbff8ab6d) Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b169821e8f68e685a0164ff2146c1a0c7f93d1a7 --- libavcodec/utils.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 39b83c7791..f96504fa44 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -259,6 +259,9 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, if (s->codec_id == AV_CODEC_ID_SVQ1) { w_align = 64; h_align = 64; +} else if (s->codec_id == AV_CODEC_ID_SNOW) { +w_align = 16; +h_align = 16; } break; case AV_PIX_FMT_RGB555: ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] swscale: [loongarch] Fix checkasm-sw_yuv2rgb failure.
ffmpeg | branch: release/6.1 | Shiyou Yin | Thu Jul 25 17:39:21 2024 +0800| [68b5f822654b437478646c70fedcb04d99e495e1] | committer: Michael Niedermayer swscale: [loongarch] Fix checkasm-sw_yuv2rgb failure. Reviewed-by: 陈昊 Signed-off-by: Michael Niedermayer (cherry picked from commit 4713a5cc2478ac94150541918749913d05a54b7f) Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=68b5f822654b437478646c70fedcb04d99e495e1 --- libswscale/loongarch/swscale_init_loongarch.c | 104 +- libswscale/loongarch/yuv2rgb_lasx.c | 4 +- 2 files changed, 56 insertions(+), 52 deletions(-) diff --git a/libswscale/loongarch/swscale_init_loongarch.c b/libswscale/loongarch/swscale_init_loongarch.c index 53e4f970b6..51bfdd56de 100644 --- a/libswscale/loongarch/swscale_init_loongarch.c +++ b/libswscale/loongarch/swscale_init_loongarch.c @@ -93,60 +93,64 @@ av_cold SwsFunc ff_yuv2rgb_init_loongarch(SwsContext *c) int cpu_flags = av_get_cpu_flags(); #if HAVE_LASX if (have_lasx(cpu_flags)) { -switch (c->dstFormat) { -case AV_PIX_FMT_RGB24: -return yuv420_rgb24_lasx; -case AV_PIX_FMT_BGR24: -return yuv420_bgr24_lasx; -case AV_PIX_FMT_RGBA: -if (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat)) { -break; -} else -return yuv420_rgba32_lasx; -case AV_PIX_FMT_ARGB: -if (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat)) { -break; -} else -return yuv420_argb32_lasx; -case AV_PIX_FMT_BGRA: -if (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat)) { -break; -} else -return yuv420_bgra32_lasx; -case AV_PIX_FMT_ABGR: -if (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat)) { -break; -} else -return yuv420_abgr32_lasx; +if (c->srcFormat == AV_PIX_FMT_YUV420P) { +switch (c->dstFormat) { +case AV_PIX_FMT_RGB24: +return yuv420_rgb24_lasx; +case AV_PIX_FMT_BGR24: +return yuv420_bgr24_lasx; +case AV_PIX_FMT_RGBA: +if (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat)) { +break; +} else +return yuv420_rgba32_lasx; +case AV_PIX_FMT_ARGB: +if (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat)) { +break; +} else +return yuv420_argb32_lasx; +case AV_PIX_FMT_BGRA: +if (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat)) { +break; +} else +return yuv420_bgra32_lasx; +case AV_PIX_FMT_ABGR: +if (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat)) { +break; +} else +return yuv420_abgr32_lasx; +} } } #endif // #if HAVE_LASX if (have_lsx(cpu_flags)) { -switch (c->dstFormat) { -case AV_PIX_FMT_RGB24: -return yuv420_rgb24_lsx; -case AV_PIX_FMT_BGR24: -return yuv420_bgr24_lsx; -case AV_PIX_FMT_RGBA: -if (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat)) { -break; -} else -return yuv420_rgba32_lsx; -case AV_PIX_FMT_ARGB: -if (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat)) { -break; -} else -return yuv420_argb32_lsx; -case AV_PIX_FMT_BGRA: -if (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat)) { -break; -} else -return yuv420_bgra32_lsx; -case AV_PIX_FMT_ABGR: -if (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat)) { -break; -} else -return yuv420_abgr32_lsx; +if (c->srcFormat == AV_PIX_FMT_YUV420P) { +switch (c->dstFormat) { +case AV_PIX_FMT_RGB24: +return yuv420_rgb24_lsx; +case AV_PIX_FMT_BGR24: +return yuv420_bgr24_lsx; +case AV_PIX_FMT_RGBA: +if (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat)) { +break; +} else +return yuv420_rgba32_lsx; +case AV_PIX_FMT_ARGB: +if (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat)) { +break; +}
[FFmpeg-cvslog] Changelog: update
ffmpeg | branch: release/6.1 | Michael Niedermayer | Fri Aug 2 00:57:11 2024 +0200| [b1a4534186ca51b0457579fc05a5739eb2cc45cd] | committer: Michael Niedermayer Changelog: update Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b1a4534186ca51b0457579fc05a5739eb2cc45cd --- Changelog | 7 +++ 1 file changed, 7 insertions(+) diff --git a/Changelog b/Changelog index e84ce60cdc..1ee8b060f3 100644 --- a/Changelog +++ b/Changelog @@ -2,6 +2,13 @@ Entries are sorted chronologically from oldest to youngest within each release, releases are sorted from youngest to oldest. version 6.1.2 + avcodec/snow: Fix off by 1 error in run_buffer + avcodec/utils: apply the same alignment to YUV410 as we do to YUV420 for snow + swscale: [loongarch] Fix checkasm-sw_yuv2rgb failure. + avcodec/pngenc: fix sBIT writing for indexed-color PNGs + avcodec/pngdec: use 8-bit sBIT cap for indexed PNGs per spec + avcodec/videotoolboxenc: Fix bitrate doesn't work as expected + Changelog: update avdevice/dshow: Don't skip audio devices if no video device is present avcodec/hdrenc: Allocate more space avcodec/cfhdenc: Height of 16 is not supported ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/snow: Fix off by 1 error in run_buffer
ffmpeg | branch: release/6.1 | Michael Niedermayer | Wed Jul 31 21:43:39 2024 +0200| [f4c70a83cfdd9379061db72823e6c61f8fbe3d72] | committer: Michael Niedermayer avcodec/snow: Fix off by 1 error in run_buffer Fixes: out of array access Fixes: 70741/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SNOW_fuzzer-5703668010647552 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer (cherry picked from commit 06f5ed40f8fceb2542add052c57608121eda2f41) Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f4c70a83cfdd9379061db72823e6c61f8fbe3d72 --- libavcodec/snow.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/snow.c b/libavcodec/snow.c index 59815d00d9..1b0fc6dc7d 100644 --- a/libavcodec/snow.c +++ b/libavcodec/snow.c @@ -427,7 +427,7 @@ av_cold int ff_snow_common_init(AVCodecContext *avctx){ !FF_ALLOCZ_TYPED_ARRAY(s->spatial_dwt_buffer, width * height) || //FIXME this does not belong here !FF_ALLOCZ_TYPED_ARRAY(s->temp_dwt_buffer, width) || !FF_ALLOCZ_TYPED_ARRAY(s->temp_idwt_buffer,width) || -!FF_ALLOCZ_TYPED_ARRAY(s->run_buffer, ((width + 1) >> 1) * ((height + 1) >> 1))) +!FF_ALLOCZ_TYPED_ARRAY(s->run_buffer, ((width + 1) >> 1) * ((height + 1) >> 1) + 1)) return AVERROR(ENOMEM); for(i=0; ihttps://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] Tag n6.1.2 : FFmpeg 6.1.2 release
[ffmpeg] [branch: refs/tags/n6.1.2] Tag:74a316ad39c2cc3c9e689a1122f2bab692dec072 > http://git.videolan.org/gitweb.cgi/ffmpeg.git?a=tag;h=74a316ad39c2cc3c9e689a1122f2bab692dec072 Tagger: Michael Niedermayer Date: Fri Aug 2 01:53:21 2024 +0200 FFmpeg 6.1.2 release ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] [ffmpeg-web] branch master updated. 0a299a8 web/download: add 6.1.2
The branch, master has been updated via 0a299a8119027bbdbaf561275df4b90ffa915e6b (commit) from 3bc7fc3ecedc23ba4d7c31a03ed82ec709f706f0 (commit) - Log - commit 0a299a8119027bbdbaf561275df4b90ffa915e6b Author: Michael Niedermayer AuthorDate: Fri Aug 2 02:00:01 2024 +0200 Commit: Michael Niedermayer CommitDate: Fri Aug 2 02:00:01 2024 +0200 web/download: add 6.1.2 diff --git a/src/download b/src/download index cdec3b7..fcd9fa7 100644 --- a/src/download +++ b/src/download @@ -341,10 +341,10 @@ libpostproc58. 1.100 - FFmpeg 6.1.1 "Heaviside" + FFmpeg 6.1.2 "Heaviside" -6.1.1 was released on 2023-12-31. It is the latest stable FFmpeg release +6.1.2 was released on 2024-08-02. It is the latest stable FFmpeg release from the 6.1 release branch, which was cut from master on 2023-10-29. It includes the following library versions: @@ -360,19 +360,19 @@ libswresample 4. 12.100 libpostproc57. 3.100 - Download xz tarball - PGP signature + Download xz tarball + PGP signature - Download bzip2 tarball - PGP signature + Download bzip2 tarball + PGP signature - Download gzip tarball - PGP signature + Download gzip tarball + PGP signature - https://git.ffmpeg.org/gitweb/ffmpeg.git/shortlog/n6.1.1";>Changelog + https://git.ffmpeg.org/gitweb/ffmpeg.git/shortlog/n6.1.2";>Changelog https://git.ffmpeg.org/gitweb/ffmpeg.git/blob/refs/heads/release/6.1:/RELEASE_NOTES";>Release Notes --- Summary of changes: src/download | 18 +- 1 file changed, 9 insertions(+), 9 deletions(-) hooks/post-receive -- ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avutil/hwcontext_videotoolbox: Correctly set trc
ffmpeg | branch: master | Gnattu OC | Fri Aug 2 07:31:03 2024 +0800| [d50f9701b63a7270922ed754a720fe76e80c0bed] | committer: Zhao Zhili avutil/hwcontext_videotoolbox: Correctly set trc The color trc key was assigned a color primaries value which causes the resulting colorspace is always SDR. Fixes #10884. Signed-off-by: Gnattu OC Signed-off-by: Zhao Zhili > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d50f9701b63a7270922ed754a720fe76e80c0bed --- libavutil/hwcontext_videotoolbox.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavutil/hwcontext_videotoolbox.c b/libavutil/hwcontext_videotoolbox.c index 1794459943..80eaab64f0 100644 --- a/libavutil/hwcontext_videotoolbox.c +++ b/libavutil/hwcontext_videotoolbox.c @@ -597,7 +597,7 @@ static int vt_pixbuf_set_colorspace(void *log_ctx, colortrc = av_map_videotoolbox_color_trc_from_av(src->color_trc); if (colortrc) CVBufferSetAttachment(pixbuf, kCVImageBufferTransferFunctionKey, -colorpri, kCVAttachmentMode_ShouldPropagate); +colortrc, kCVAttachmentMode_ShouldPropagate); else { CVBufferRemoveAttachment(pixbuf, kCVImageBufferTransferFunctionKey); if (src->color_trc != AVCOL_TRC_UNSPECIFIED) ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".