[PATCH 1/8] configure: Remove dependencies of inexistant rtjpeg decoder
rtjpeg is a mode of nuv and not a decoder in its own right. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- configure | 1 - 1 file changed, 1 deletion(-) diff --git a/configure b/configure index ab6ff27249..2c4f5043d5 100755 --- a/configure +++ b/configure @@ -2934,7 +2934,6 @@ ralf_decoder_select="golomb" rasc_decoder_select="inflate_wrapper" rawvideo_decoder_select="bswapdsp" rscc_decoder_deps="zlib" -rtjpeg_decoder_select="me_cmp" rv10_decoder_select="h263_decoder" rv10_encoder_select="h263_encoder" rv20_decoder_select="h263_decoder" -- 2.34.1
Fixes builds with --disable-everything --disable-faan. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- configure | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configure b/configure index 2c4f5043d5..c983c689ec 100755 --- a/configure +++ b/configure @@ -2926,6 +2926,8 @@ png_decoder_select="inflate_wrapper" png_encoder_select="deflate_wrapper llvidencdsp" prores_decoder_select="blockdsp idctdsp" prores_encoder_select="fdctdsp" +prores_aw_encoder_select="fdctdsp" +prores_ks_encoder_select="fdctdsp" qcelp_decoder_select="lsp" qdm2_decoder_select="mdct rdft mpegaudiodsp" ra_144_decoder_select="audiodsp" -- 2.34.1
Currently masked by an unnecessary me_cmp->fdctdsp dependency. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index c983c689ec..406ac996b7 100755 --- a/configure +++ b/configure @@ -2755,7 +2755,7 @@ mpegaudio_select="mpegaudiodsp mpegaudioheader" mpegaudiodsp_select="dct" mpegvideo_select="blockdsp h264chroma hpeldsp idctdsp videodsp" mpegvideodec_select="mpegvideo mpeg_er" -mpegvideoenc_select="aandcttables me_cmp mpegvideo pixblockdsp qpeldsp" +mpegvideoenc_select="aandcttables fdctdsp me_cmp mpegvideo pixblockdsp qpeldsp" msmpeg4dec_select="h263_decoder" msmpeg4enc_select="h263_encoder" vc1dsp_select="h264chroma qpeldsp startcode" -- 2.34.1
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 406ac996b7..689a6111c5 100755 --- a/configure +++ b/configure @@ -2749,7 +2749,7 @@ intrax8_select="blockdsp wmv2dsp" iso_media_select="mpeg4audio" mdct_select="fft" mdct15_select="fft" -me_cmp_select="fdctdsp idctdsp pixblockdsp" +me_cmp_select="idctdsp" mpeg_er_select="error_resilience" mpegaudio_select="mpegaudiodsp mpegaudioheader" mpegaudiodsp_select="dct" -- 2.34.1
The binkaudio decoders don't need mdct or sinewin at all; and binkaudio_dct doesn't need rdft directly (but nevertheless uses it indirectly via dct). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- configure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 689a6111c5..0d166de7a2 100755 --- a/configure +++ b/configure @@ -2797,8 +2797,8 @@ atrac3pal_decoder_select="mdct sinewin" atrac9_decoder_select="mdct" av1_decoder_select="av1_frame_split_bsf cbs_av1" bink_decoder_select="blockdsp hpeldsp" -binkaudio_dct_decoder_select="mdct rdft dct sinewin wma_freqs" -binkaudio_rdft_decoder_select="mdct rdft sinewin wma_freqs" +binkaudio_dct_decoder_select="dct wma_freqs" +binkaudio_rdft_decoder_select="rdft wma_freqs" cavs_decoder_select="blockdsp golomb h264chroma idctdsp qpeldsp videodsp" clearvideo_decoder_select="idctdsp" cllc_decoder_select="bswapdsp" -- 2.34.1
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 0d166de7a2..636141ae1e 100755 --- a/configure +++ b/configure @@ -2929,7 +2929,7 @@ prores_encoder_select="fdctdsp" prores_aw_encoder_select="fdctdsp" prores_ks_encoder_select="fdctdsp" qcelp_decoder_select="lsp" -qdm2_decoder_select="mdct rdft mpegaudiodsp" +qdm2_decoder_select="rdft mpegaudiodsp" ra_144_decoder_select="audiodsp" ra_144_encoder_select="audio_frame_queue lpc audiodsp" ralf_decoder_select="golomb" -- 2.34.1
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 636141ae1e..ad960452d0 100755 --- a/configure +++ b/configure @@ -3000,7 +3000,7 @@ wmav1_decoder_select="mdct sinewin wma_freqs" wmav1_encoder_select="mdct sinewin wma_freqs" wmav2_decoder_select="mdct sinewin wma_freqs" wmav2_encoder_select="mdct sinewin wma_freqs" -wmavoice_decoder_select="lsp rdft dct mdct sinewin" +wmavoice_decoder_select="lsp rdft dct sinewin" wmv1_decoder_select="msmpeg4dec" wmv1_encoder_select="msmpeg4enc" wmv2_decoder_select="blockdsp error_resilience idctdsp intrax8 msmpeg4dec videodsp wmv2dsp" -- 2.34.1
These encoders currently rely on an implicit dependency via mpegvideo. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- configure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index ad960452d0..b16a46cab8 100755 --- a/configure +++ b/configure @@ -2811,7 +2811,7 @@ dca_encoder_select="mdct" dds_decoder_select="texturedsp" dirac_decoder_select="dirac_parse dwt golomb videodsp mpegvideoenc" dnxhd_decoder_select="blockdsp idctdsp" -dnxhd_encoder_select="blockdsp fdctdsp idctdsp mpegvideoenc pixblockdsp" +dnxhd_encoder_select="blockdsp fdctdsp idctdsp mpegvideoenc pixblockdsp videodsp" dolby_e_decoder_select="mdct" dvvideo_decoder_select="dvprofile idctdsp" dvvideo_encoder_select="dvprofile fdctdsp me_cmp pixblockdsp" @@ -2947,7 +2947,7 @@ shorten_decoder_select="bswapdsp" sipr_decoder_select="lsp" smvjpeg_decoder_select="mjpeg_decoder" snow_decoder_select="dwt h264qpel hpeldsp me_cmp rangecoder videodsp" -snow_encoder_select="dwt h264qpel hpeldsp me_cmp mpegvideoenc rangecoder" +snow_encoder_select="dwt h264qpel hpeldsp me_cmp mpegvideoenc rangecoder videodsp" sonic_decoder_select="golomb rangecoder" sonic_encoder_select="golomb rangecoder" sonic_ls_encoder_select="golomb rangecoder" -- 2.34.1
Only used by the encoder. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- configure | 2 +- libavcodec/snow.c | 2 -- libavcodec/snowenc.c | 2 ++ 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/configure b/configure index b16a46cab8..f3fd91f592 100755 --- a/configure +++ b/configure @@ -2946,7 +2946,7 @@ screenpresso_decoder_deps="zlib" shorten_decoder_select="bswapdsp" sipr_decoder_select="lsp" smvjpeg_decoder_select="mjpeg_decoder" -snow_decoder_select="dwt h264qpel hpeldsp me_cmp rangecoder videodsp" +snow_decoder_select="dwt h264qpel hpeldsp rangecoder videodsp" snow_encoder_select="dwt h264qpel hpeldsp me_cmp mpegvideoenc rangecoder videodsp" sonic_decoder_select="golomb rangecoder" sonic_encoder_select="golomb rangecoder" diff --git a/libavcodec/snow.c b/libavcodec/snow.c index aa15fccc42..cde09902c3 100644 --- a/libavcodec/snow.c +++ b/libavcodec/snow.c @@ -23,7 +23,6 @@ #include "avcodec.h" #include "decode.h" #include "encode.h" -#include "me_cmp.h" #include "snow_dwt.h" #include "snow.h" #include "snowdata.h" @@ -434,7 +433,6 @@ av_cold int ff_snow_common_init(AVCodecContext *avctx){ s->max_ref_frames=1; //just make sure it's not an invalid value in case of no initial keyframe s->spatial_decomposition_count = 1; - ff_me_cmp_init(&s->mecc, avctx); ff_hpeldsp_init(&s->hdsp, avctx->flags); ff_videodsp_init(&s->vdsp, 8); ff_dwt_init(&s->dwt); diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c index c5ff50639e..ea0d4fc27f 100644 --- a/libavcodec/snowenc.c +++ b/libavcodec/snowenc.c @@ -26,6 +26,7 @@ #include "avcodec.h" #include "codec_internal.h" #include "encode.h" +#include "me_cmp.h" #include "packet_internal.h" #include "snow_dwt.h" #include "snow.h" @@ -66,6 +67,7 @@ static av_cold int encode_init(AVCodecContext *avctx) if ((ret = ff_snow_common_init(avctx)) < 0) { return ret; } + ff_me_cmp_init(&s->mecc, avctx); ff_mpegvideoencdsp_init(&s->mpvencdsp, avctx); ff_snow_alloc_blocks(s); -- 2.34.1
On Mon, Oct 10, 2022 at 05:12:59AM +0200, Andreas Rheinhardt wrote:
Only used by the encoder.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- configure | 2 +- libavcodec/snow.c | 2 -- libavcodec/snowenc.c | 2 ++ 3 files changed, 3 insertions(+), 3 deletions(-)
LGTM thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Those who are too smart to engage in politics are punished by being governed by those who are dumber. -- Plato
Only used by the encoder. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/snow.c | 25 ------------------------- libavcodec/snowenc.c | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/libavcodec/snow.c b/libavcodec/snow.c index cde09902c3..c9bc4dbab9 100644 --- a/libavcodec/snow.c +++ b/libavcodec/snow.c @@ -438,31 +438,6 @@ av_cold int ff_snow_common_init(AVCodecContext *avctx){ ff_dwt_init(&s->dwt); ff_h264qpel_init(&s->h264qpel, 8); -#define mcf(dx,dy)\ - s->qdsp.put_qpel_pixels_tab [0][dy+dx/4]=\ - s->qdsp.put_no_rnd_qpel_pixels_tab[0][dy+dx/4]=\ - s->h264qpel.put_h264_qpel_pixels_tab[0][dy+dx/4];\ - s->qdsp.put_qpel_pixels_tab [1][dy+dx/4]=\ - s->qdsp.put_no_rnd_qpel_pixels_tab[1][dy+dx/4]=\ - s->h264qpel.put_h264_qpel_pixels_tab[1][dy+dx/4]; - - mcf( 0, 0) - mcf( 4, 0) - mcf( 8, 0) - mcf(12, 0) - mcf( 0, 4) - mcf( 4, 4) - mcf( 8, 4) - mcf(12, 4) - mcf( 0, 8) - mcf( 4, 8) - mcf( 8, 8) - mcf(12, 8) - mcf( 0,12) - mcf( 4,12) - mcf( 8,12) - mcf(12,12) - #define mcfh(dx,dy)\ s->hdsp.put_pixels_tab [0][dy/4+dx/8]=\ s->hdsp.put_no_rnd_pixels_tab[0][dy/4+dx/8]=\ diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c index ea0d4fc27f..929edc1340 100644 --- a/libavcodec/snowenc.c +++ b/libavcodec/snowenc.c @@ -67,6 +67,32 @@ static av_cold int encode_init(AVCodecContext *avctx) if ((ret = ff_snow_common_init(avctx)) < 0) { return ret; } + +#define mcf(dx,dy)\ + s->qdsp.put_qpel_pixels_tab [0][dy+dx/4]=\ + s->qdsp.put_no_rnd_qpel_pixels_tab[0][dy+dx/4]=\ + s->h264qpel.put_h264_qpel_pixels_tab[0][dy+dx/4];\ + s->qdsp.put_qpel_pixels_tab [1][dy+dx/4]=\ + s->qdsp.put_no_rnd_qpel_pixels_tab[1][dy+dx/4]=\ + s->h264qpel.put_h264_qpel_pixels_tab[1][dy+dx/4]; + + mcf( 0, 0) + mcf( 4, 0) + mcf( 8, 0) + mcf(12, 0) + mcf( 0, 4) + mcf( 4, 4) + mcf( 8, 4) + mcf(12, 4) + mcf( 0, 8) + mcf( 4, 8) + mcf( 8, 8) + mcf(12, 8) + mcf( 0,12) + mcf( 4,12) + mcf( 8,12) + mcf(12,12) + ff_me_cmp_init(&s->mecc, avctx); ff_mpegvideoencdsp_init(&s->mpvencdsp, avctx); -- 2.34.1
Andreas Rheinhardt:
Only used by the encoder.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/snow.c | 25 ------------------------- libavcodec/snowenc.c | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 25 deletions(-)
diff --git a/libavcodec/snow.c b/libavcodec/snow.c index cde09902c3..c9bc4dbab9 100644 --- a/libavcodec/snow.c +++ b/libavcodec/snow.c @@ -438,31 +438,6 @@ av_cold int ff_snow_common_init(AVCodecContext *avctx){ ff_dwt_init(&s->dwt); ff_h264qpel_init(&s->h264qpel, 8);
-#define mcf(dx,dy)\ - s->qdsp.put_qpel_pixels_tab [0][dy+dx/4]=\ - s->qdsp.put_no_rnd_qpel_pixels_tab[0][dy+dx/4]=\ - s->h264qpel.put_h264_qpel_pixels_tab[0][dy+dx/4];\ - s->qdsp.put_qpel_pixels_tab [1][dy+dx/4]=\ - s->qdsp.put_no_rnd_qpel_pixels_tab[1][dy+dx/4]=\ - s->h264qpel.put_h264_qpel_pixels_tab[1][dy+dx/4]; - - mcf( 0, 0) - mcf( 4, 0) - mcf( 8, 0) - mcf(12, 0) - mcf( 0, 4) - mcf( 4, 4) - mcf( 8, 4) - mcf(12, 4) - mcf( 0, 8) - mcf( 4, 8) - mcf( 8, 8) - mcf(12, 8) - mcf( 0,12) - mcf( 4,12) - mcf( 8,12) - mcf(12,12) - #define mcfh(dx,dy)\ s->hdsp.put_pixels_tab [0][dy/4+dx/8]=\ s->hdsp.put_no_rnd_pixels_tab[0][dy/4+dx/8]=\ diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c index ea0d4fc27f..929edc1340 100644 --- a/libavcodec/snowenc.c +++ b/libavcodec/snowenc.c @@ -67,6 +67,32 @@ static av_cold int encode_init(AVCodecContext *avctx) if ((ret = ff_snow_common_init(avctx)) < 0) { return ret; } + +#define mcf(dx,dy)\ + s->qdsp.put_qpel_pixels_tab [0][dy+dx/4]=\ + s->qdsp.put_no_rnd_qpel_pixels_tab[0][dy+dx/4]=\ + s->h264qpel.put_h264_qpel_pixels_tab[0][dy+dx/4];\ + s->qdsp.put_qpel_pixels_tab [1][dy+dx/4]=\ + s->qdsp.put_no_rnd_qpel_pixels_tab[1][dy+dx/4]=\ + s->h264qpel.put_h264_qpel_pixels_tab[1][dy+dx/4]; + + mcf( 0, 0) + mcf( 4, 0) + mcf( 8, 0) + mcf(12, 0) + mcf( 0, 4) + mcf( 4, 4) + mcf( 8, 4) + mcf(12, 4) + mcf( 0, 8) + mcf( 4, 8) + mcf( 8, 8) + mcf(12, 8) + mcf( 0,12) + mcf( 4,12) + mcf( 8,12) + mcf(12,12) + ff_me_cmp_init(&s->mecc, avctx); ff_mpegvideoencdsp_init(&s->mpvencdsp, avctx);
Will apply patches 10-13 tomorrow unless there are objections. - Andreas
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/snow.h | 219 ------------------------------------------- libavcodec/snowdec.c | 147 +++++++++++++++++++++++++++++ libavcodec/snowenc.c | 64 +++++++++++++ 3 files changed, 211 insertions(+), 219 deletions(-) diff --git a/libavcodec/snow.h b/libavcodec/snow.h index ed0f9abb42..8da3d99885 100644 --- a/libavcodec/snow.h +++ b/libavcodec/snow.h @@ -486,227 +486,8 @@ static inline void set_blocks(SnowContext *s, int level, int x, int y, int l, in } } -static inline void init_ref(MotionEstContext *c, const uint8_t *const src[3], uint8_t *const ref[3], uint8_t *const ref2[3], int x, int y, int ref_index){ - SnowContext *s = c->avctx->priv_data; - const int offset[3]= { - y*c-> stride + x, - ((y*c->uvstride + x)>>s->chroma_h_shift), - ((y*c->uvstride + x)>>s->chroma_h_shift), - }; - int i; - for(i=0; i<3; i++){ - c->src[0][i]= src [i]; - c->ref[0][i]= ref [i] + offset[i]; - } - av_assert2(!ref_index); -} - - -/* bitstream functions */ - extern const int8_t ff_quant3bA[256]; #define QEXPSHIFT (7-FRAC_BITS+8) //FIXME try to change this to 0 -static inline void put_symbol(RangeCoder *c, uint8_t *state, int v, int is_signed){ - int i; - - if(v){ - const int a= FFABS(v); - const int e= av_log2(a); - const int el= FFMIN(e, 10); - put_rac(c, state+0, 0); - - for(i=0; i<el; i++){ - put_rac(c, state+1+i, 1); //1..10 - } - for(; i<e; i++){ - put_rac(c, state+1+9, 1); //1..10 - } - put_rac(c, state+1+FFMIN(i,9), 0); - - for(i=e-1; i>=el; i--){ - put_rac(c, state+22+9, (a>>i)&1); //22..31 - } - for(; i>=0; i--){ - put_rac(c, state+22+i, (a>>i)&1); //22..31 - } - - if(is_signed) - put_rac(c, state+11 + el, v < 0); //11..21 - }else{ - put_rac(c, state+0, 1); - } -} - -static inline int get_symbol(RangeCoder *c, uint8_t *state, int is_signed){ - if(get_rac(c, state+0)) - return 0; - else{ - int i, e; - unsigned a; - e= 0; - while(get_rac(c, state+1 + FFMIN(e,9))){ //1..10 - e++; - if (e > 31) - return AVERROR_INVALIDDATA; - } - - a= 1; - for(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 - return (a^e)-e; - } -} - -static inline void put_symbol2(RangeCoder *c, uint8_t *state, int v, int log2){ - int i; - int r= log2>=0 ? 1<<log2 : 1; - - av_assert2(v>=0); - av_assert2(log2>=-4); - - while(v >= r){ - put_rac(c, state+4+log2, 1); - v -= r; - log2++; - if(log2>0) r+=r; - } - put_rac(c, state+4+log2, 0); - - for(i=log2-1; i>=0; i--){ - put_rac(c, state+31-i, (v>>i)&1); - } -} - -static inline int get_symbol2(RangeCoder *c, uint8_t *state, int log2){ - int i; - int r= log2>=0 ? 1<<log2 : 1; - int v=0; - - av_assert2(log2>=-4); - - while(log2<28 && get_rac(c, state+4+log2)){ - v+= r; - log2++; - if(log2>0) r+=r; - } - - for(i=log2-1; i>=0; i--){ - v+= get_rac(c, state+31-i)<<i; - } - - return v; -} - -static inline void unpack_coeffs(SnowContext *s, SubBand *b, SubBand * parent, int orientation){ - const int w= b->width; - const int h= b->height; - int x,y; - - int run, runs; - x_and_coeff *xc= b->x_coeff; - x_and_coeff *prev_xc= NULL; - x_and_coeff *prev2_xc= xc; - x_and_coeff *parent_xc= parent ? parent->x_coeff : NULL; - x_and_coeff *prev_parent_xc= parent_xc; - - runs= get_symbol2(&s->c, b->state[30], 0); - if(runs-- > 0) run= get_symbol2(&s->c, b->state[1], 3); - else run= INT_MAX; - - for(y=0; y<h; y++){ - int v=0; - int lt=0, t=0, rt=0; - - if(y && prev_xc->x == 0){ - rt= prev_xc->coeff; - } - for(x=0; x<w; x++){ - int p=0; - const int l= v; - - lt= t; t= rt; - - if(y){ - if(prev_xc->x <= x) - prev_xc++; - if(prev_xc->x == x + 1) - rt= prev_xc->coeff; - else - rt=0; - } - if(parent_xc){ - if(x>>1 > parent_xc->x){ - parent_xc++; - } - if(x>>1 == parent_xc->x){ - p= parent_xc->coeff; - } - } - if(/*ll|*/l|lt|t|rt|p){ - int context= av_log2(/*FFABS(ll) + */3*(l>>1) + (lt>>1) + (t&~1) + (rt>>1) + (p>>1)); - - v=get_rac(&s->c, &b->state[0][context]); - if(v){ - v= 2*(get_symbol2(&s->c, b->state[context + 2], context-4) + 1); - v+=get_rac(&s->c, &b->state[0][16 + 1 + 3 + ff_quant3bA[l&0xFF] + 3*ff_quant3bA[t&0xFF]]); - if ((uint16_t)v != v) { - av_log(s->avctx, AV_LOG_ERROR, "Coefficient damaged\n"); - v = 1; - } - xc->x=x; - (xc++)->coeff= v; - } - }else{ - if(!run){ - if(runs-- > 0) run= get_symbol2(&s->c, b->state[1], 3); - else run= INT_MAX; - v= 2*(get_symbol2(&s->c, b->state[0 + 2], 0-4) + 1); - v+=get_rac(&s->c, &b->state[0][16 + 1 + 3]); - if ((uint16_t)v != v) { - av_log(s->avctx, AV_LOG_ERROR, "Coefficient damaged\n"); - v = 1; - } - - xc->x=x; - (xc++)->coeff= v; - }else{ - int max_run; - run--; - v=0; - av_assert2(run >= 0); - if(y) max_run= FFMIN(run, prev_xc->x - x - 2); - else max_run= FFMIN(run, w-x-1); - if(parent_xc) - max_run= FFMIN(max_run, 2*parent_xc->x - x - 1); - av_assert2(max_run >= 0 && max_run <= run); - - x+= max_run; - run-= max_run; - } - } - } - (xc++)->x= w+1; //end marker - prev_xc= prev2_xc; - prev2_xc= xc; - - if(parent_xc){ - if(y&1){ - while(parent_xc->x != parent->width+1) - parent_xc++; - parent_xc++; - prev_parent_xc= parent_xc; - }else{ - parent_xc= prev_parent_xc; - } - } - } - - (xc++)->x= w+1; //end marker -} - #endif /* AVCODEC_SNOW_H */ diff --git a/libavcodec/snowdec.c b/libavcodec/snowdec.c index 5c95ffde11..3a835650a5 100644 --- a/libavcodec/snowdec.c +++ b/libavcodec/snowdec.c @@ -29,6 +29,153 @@ #include "rangecoder.h" #include "mathops.h" +static inline int get_symbol(RangeCoder *c, uint8_t *state, int is_signed) +{ + if (get_rac(c, state + 0)) + return 0; + else { + int e; + unsigned a; + e = 0; + while (get_rac(c, state + 1 + FFMIN(e, 9))) { //1..10 + e++; + if (e > 31) + return AVERROR_INVALIDDATA; + } + + a = 1; + 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 + return (a ^ e) - e; + } +} + +static inline int get_symbol2(RangeCoder *c, uint8_t *state, int log2) +{ + int r = log2 >= 0 ? 1 << log2 : 1; + int v = 0; + + av_assert2(log2 >= -4); + + while (log2 < 28 && get_rac(c, state + 4 + log2)) { + v += r; + log2++; + if (log2 > 0) r += r; + } + + for (int i = log2 - 1; i >= 0; i--) + v += get_rac(c, state + 31 - i) << i; + + return v; +} + +static void unpack_coeffs(SnowContext *s, SubBand *b, SubBand * parent, int orientation) +{ + const int w = b->width; + const int h = b->height; + + int run, runs; + x_and_coeff *xc = b->x_coeff; + x_and_coeff *prev_xc = NULL; + x_and_coeff *prev2_xc = xc; + x_and_coeff *parent_xc = parent ? parent->x_coeff : NULL; + x_and_coeff *prev_parent_xc = parent_xc; + + runs = get_symbol2(&s->c, b->state[30], 0); + if (runs-- > 0) run = get_symbol2(&s->c, b->state[1], 3); + else run = INT_MAX; + + for (int y = 0; y < h; y++) { + int v = 0; + int lt = 0, t = 0, rt = 0; + + if (y && prev_xc->x == 0) + rt = prev_xc->coeff; + + for (int x = 0; x < w; x++) { + int p = 0; + const int l = v; + + lt= t; t= rt; + + if (y) { + if (prev_xc->x <= x) + prev_xc++; + if (prev_xc->x == x + 1) + rt = prev_xc->coeff; + else + rt = 0; + } + if (parent_xc) { + if (x>>1 > parent_xc->x) + parent_xc++; + if (x>>1 == parent_xc->x) + p = parent_xc->coeff; + } + if (/*ll|*/l|lt|t|rt|p) { + int context = av_log2(/*FFABS(ll) + */3*(l>>1) + (lt>>1) + (t&~1) + (rt>>1) + (p>>1)); + + v = get_rac(&s->c, &b->state[0][context]); + if (v) { + v = 2*(get_symbol2(&s->c, b->state[context + 2], context-4) + 1); + v += get_rac(&s->c, &b->state[0][16 + 1 + 3 + ff_quant3bA[l&0xFF] + 3 * ff_quant3bA[t&0xFF]]); + if ((uint16_t)v != v) { + av_log(s->avctx, AV_LOG_ERROR, "Coefficient damaged\n"); + v = 1; + } + xc->x = x; + (xc++)->coeff = v; + } + } else { + if (!run) { + if (runs-- > 0) run = get_symbol2(&s->c, b->state[1], 3); + else run = INT_MAX; + v = 2 * (get_symbol2(&s->c, b->state[0 + 2], 0-4) + 1); + v += get_rac(&s->c, &b->state[0][16 + 1 + 3]); + if ((uint16_t)v != v) { + av_log(s->avctx, AV_LOG_ERROR, "Coefficient damaged\n"); + v = 1; + } + + xc->x = x; + (xc++)->coeff = v; + } else { + int max_run; + run--; + v = 0; + av_assert2(run >= 0); + if (y) max_run = FFMIN(run, prev_xc->x - x - 2); + else max_run = FFMIN(run, w-x-1); + if (parent_xc) + max_run = FFMIN(max_run, 2*parent_xc->x - x - 1); + av_assert2(max_run >= 0 && max_run <= run); + + x += max_run; + run -= max_run; + } + } + } + (xc++)->x = w+1; //end marker + prev_xc = prev2_xc; + prev2_xc = xc; + + if (parent_xc) { + if (y & 1) { + while (parent_xc->x != parent->width+1) + parent_xc++; + parent_xc++; + prev_parent_xc= parent_xc; + } else { + parent_xc= prev_parent_xc; + } + } + } + + (xc++)->x = w + 1; //end marker +} + static av_always_inline void predict_slice_buffered(SnowContext *s, slice_buffer * sb, IDWTELEM * old_buffer, int plane_index, int add, int mb_y){ Plane *p= &s->plane[plane_index]; const int mb_w= s->b_width << s->block_max_depth; diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c index 929edc1340..addca0ced9 100644 --- a/libavcodec/snowenc.c +++ b/libavcodec/snowenc.c @@ -37,6 +37,70 @@ #include "mpegvideo.h" #include "h263enc.h" +static void init_ref(MotionEstContext *c, const uint8_t *const src[3], + uint8_t *const ref[3], uint8_t *const ref2[3], + int x, int y, int ref_index) +{ + SnowContext *s = c->avctx->priv_data; + const int offset[3] = { + y*c-> stride + x, + ((y*c->uvstride + x) >> s->chroma_h_shift), + ((y*c->uvstride + x) >> s->chroma_h_shift), + }; + for (int i = 0; i < 3; i++) { + c->src[0][i] = src [i]; + c->ref[0][i] = ref [i] + offset[i]; + } + av_assert2(!ref_index); +} + +static inline void put_symbol(RangeCoder *c, uint8_t *state, int v, int is_signed) +{ + if (v) { + const int a = FFABS(v); + const int e = av_log2(a); + const int el = FFMIN(e, 10); + int i; + + put_rac(c, state + 0, 0); + + for (i = 0; i < el; i++) + put_rac(c, state + 1 + i, 1); //1..10 + for(; i < e; i++) + put_rac(c, state + 1 + 9, 1); //1..10 + put_rac(c, state + 1 + FFMIN(i, 9), 0); + + for (i = e - 1; i >= el; i--) + put_rac(c, state + 22 + 9, (a >> i) & 1); //22..31 + for(; i >= 0; i--) + put_rac(c, state + 22 + i, (a >> i) & 1); //22..31 + + if (is_signed) + put_rac(c, state + 11 + el, v < 0); //11..21 + } else { + put_rac(c, state + 0, 1); + } +} + +static inline void put_symbol2(RangeCoder *c, uint8_t *state, int v, int log2) +{ + int r = log2 >= 0 ? 1<<log2 : 1; + + av_assert2(v >= 0); + av_assert2(log2 >= -4); + + while (v >= r) { + put_rac(c, state + 4 + log2, 1); + v -= r; + log2++; + if (log2 > 0) r += r; + } + put_rac(c, state + 4 + log2, 0); + + for (int i = log2 - 1; i >= 0; i--) + put_rac(c, state + 31 - i, (v >> i) & 1); +} + static av_cold int encode_init(AVCodecContext *avctx) { SnowContext *s = avctx->priv_data; -- 2.34.1
On Mon, Oct 10, 2022 at 05:13:01AM +0200, Andreas Rheinhardt wrote:
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/snow.h | 219 ------------------------------------------- libavcodec/snowdec.c | 147 +++++++++++++++++++++++++++++ libavcodec/snowenc.c | 64 +++++++++++++ 3 files changed, 211 insertions(+), 219 deletions(-)
i guess if snow stays monolithically in 2 files thats ok thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB If you fake or manipulate statistics in a paper in physics you will never get a job again. If you fake or manipulate statistics in a paper in medicin you will get a job for life at the pharma industry.
Only used by the encoder. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- configure | 2 +- libavcodec/snow.c | 1 - libavcodec/snowenc.c | 2 ++ 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/configure b/configure index f3fd91f592..bccbf1bdbf 100755 --- a/configure +++ b/configure @@ -2946,7 +2946,7 @@ screenpresso_decoder_deps="zlib" shorten_decoder_select="bswapdsp" sipr_decoder_select="lsp" smvjpeg_decoder_select="mjpeg_decoder" -snow_decoder_select="dwt h264qpel hpeldsp rangecoder videodsp" +snow_decoder_select="dwt h264qpel rangecoder videodsp" snow_encoder_select="dwt h264qpel hpeldsp me_cmp mpegvideoenc rangecoder videodsp" sonic_decoder_select="golomb rangecoder" sonic_encoder_select="golomb rangecoder" diff --git a/libavcodec/snow.c b/libavcodec/snow.c index c9bc4dbab9..4a6c781a95 100644 --- a/libavcodec/snow.c +++ b/libavcodec/snow.c @@ -433,7 +433,6 @@ av_cold int ff_snow_common_init(AVCodecContext *avctx){ s->max_ref_frames=1; //just make sure it's not an invalid value in case of no initial keyframe s->spatial_decomposition_count = 1; - ff_hpeldsp_init(&s->hdsp, avctx->flags); ff_videodsp_init(&s->vdsp, 8); ff_dwt_init(&s->dwt); ff_h264qpel_init(&s->h264qpel, 8); diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c index addca0ced9..0854f78da7 100644 --- a/libavcodec/snowenc.c +++ b/libavcodec/snowenc.c @@ -128,6 +128,8 @@ static av_cold int encode_init(AVCodecContext *avctx) s->plane[plane_index].fast_mc= 1; } + // Must be before ff_snow_common_init() + ff_hpeldsp_init(&s->hdsp, avctx->flags); if ((ret = ff_snow_common_init(avctx)) < 0) { return ret; } -- 2.34.1
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/snow.c | 8 -------- libavcodec/snowenc.c | 12 ++++++++++++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/libavcodec/snow.c b/libavcodec/snow.c index 4a6c781a95..f55b3310ac 100644 --- a/libavcodec/snow.c +++ b/libavcodec/snow.c @@ -606,19 +606,11 @@ av_cold void ff_snow_common_end(SnowContext *s) av_freep(&s->temp_idwt_buffer); av_freep(&s->run_buffer); - s->m.me.temp= NULL; - av_freep(&s->m.me.scratchpad); - av_freep(&s->m.me.map); - av_freep(&s->m.me.score_map); - av_freep(&s->m.sc.obmc_scratchpad); - av_freep(&s->block); av_freep(&s->scratchbuf); av_freep(&s->emu_edge_buffer); for(i=0; i<MAX_REF_FRAMES; i++){ - av_freep(&s->ref_mvs[i]); - av_freep(&s->ref_scores[i]); if(s->last_picture[i] && s->last_picture[i]->data[0]) { av_assert0(s->last_picture[i]->data[0] != s->current_picture->data[0]); } diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c index 0854f78da7..fec061a8c5 100644 --- a/libavcodec/snowenc.c +++ b/libavcodec/snowenc.c @@ -1986,6 +1986,18 @@ static av_cold int encode_end(AVCodecContext *avctx) ff_snow_common_end(s); ff_rate_control_uninit(&s->m); av_frame_free(&s->input_picture); + + for (int i = 0; i < MAX_REF_FRAMES; i++) { + av_freep(&s->ref_mvs[i]); + av_freep(&s->ref_scores[i]); + } + + s->m.me.temp = NULL; + av_freep(&s->m.me.scratchpad); + av_freep(&s->m.me.map); + av_freep(&s->m.me.score_map); + av_freep(&s->m.sc.obmc_scratchpad); + av_freep(&avctx->stats_out); return 0; -- 2.34.1
On Mon, Oct 10, 2022 at 05:13:03AM +0200, Andreas Rheinhardt wrote:
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/snow.c | 8 -------- libavcodec/snowenc.c | 12 ++++++++++++ 2 files changed, 12 insertions(+), 8 deletions(-)
should be ok thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Into a blind darkness they enter who follow after the Ignorance, they as if into a greater darkness enter who devote themselves to the Knowledge alone. -- Isha Upanishad
And use its presence to check whether buffers should be allocated for it in ff_snow_common_init_after_header(). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/snow.c | 18 +++++++++--------- libavcodec/snowdec.c | 15 ++++++++++++++- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/libavcodec/snow.c b/libavcodec/snow.c index f55b3310ac..7fb1660dd6 100644 --- a/libavcodec/snow.c +++ b/libavcodec/snow.c @@ -468,9 +468,8 @@ av_cold int ff_snow_common_init(AVCodecContext *avctx){ return AVERROR(ENOMEM); } - s->mconly_picture = av_frame_alloc(); s->current_picture = av_frame_alloc(); - if (!s->mconly_picture || !s->current_picture) + if (!s->current_picture) return AVERROR(ENOMEM); ff_thread_once(&init_static_once, snow_static_init); @@ -481,22 +480,24 @@ av_cold int ff_snow_common_init(AVCodecContext *avctx){ int ff_snow_common_init_after_header(AVCodecContext *avctx) { SnowContext *s = avctx->priv_data; int plane_index, level, orientation; - int ret, emu_buf_size; + int ret; if(!s->scratchbuf) { - if (av_codec_is_decoder(avctx->codec)) { + size_t size = 2U * avctx->width + 256; + + if (s->mconly_picture) { if ((ret = ff_get_buffer(s->avctx, s->mconly_picture, AV_GET_BUFFER_FLAG_REF)) < 0) return ret; + size = FFMAX(FFABS(s->mconly_picture->linesize[0]), size); } - emu_buf_size = FFMAX(s->mconly_picture->linesize[0], 2*avctx->width+256) * (2 * MB_SIZE + HTAPS_MAX - 1); - if (!FF_ALLOCZ_TYPED_ARRAY(s->scratchbuf, FFMAX(s->mconly_picture->linesize[0], 2*avctx->width+256) * 7 * MB_SIZE) || - !FF_ALLOCZ_TYPED_ARRAY(s->emu_edge_buffer, emu_buf_size)) + if (!(s->scratchbuf = av_calloc(size, 7 * MB_SIZE)) || + !(s->emu_edge_buffer = av_calloc(size, 2 * MB_SIZE + HTAPS_MAX - 1))) return AVERROR(ENOMEM); } - if (av_codec_is_decoder(avctx->codec) && + if (s->mconly_picture && s->mconly_picture->format != avctx->pix_fmt) { av_log(avctx, AV_LOG_ERROR, "pixel format changed\n"); return AVERROR_INVALIDDATA; @@ -626,6 +627,5 @@ av_cold void ff_snow_common_end(SnowContext *s) } } } - av_frame_free(&s->mconly_picture); av_frame_free(&s->current_picture); } diff --git a/libavcodec/snowdec.c b/libavcodec/snowdec.c index 3a835650a5..96221b9802 100644 --- a/libavcodec/snowdec.c +++ b/libavcodec/snowdec.c @@ -794,19 +794,32 @@ static av_cold int decode_end(AVCodecContext *avctx) ff_snow_common_end(s); + av_frame_free(&s->mconly_picture); + s->avmv_size = 0; av_freep(&s->avmv); return 0; } +static av_cold int snow_decode_init(AVCodecContext *avctx) +{ + SnowContext *const s = avctx->priv_data; + + s->mconly_picture = av_frame_alloc(); + if (!s->mconly_picture) + return AVERROR(ENOMEM); + + return ff_snow_common_init(avctx); +} + const FFCodec ff_snow_decoder = { .p.name = "snow", CODEC_LONG_NAME("Snow"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_SNOW, .priv_data_size = sizeof(SnowContext), - .init = ff_snow_common_init, + .init = snow_decode_init, .close = decode_end, FF_CODEC_DECODE_CB(decode_frame), .p.capabilities = AV_CODEC_CAP_DR1 /*| AV_CODEC_CAP_DRAW_HORIZ_BAND*/, -- 2.34.1
Maybe zeroing spatial_idwt_buffer was intended? Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/snowdec.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavcodec/snowdec.c b/libavcodec/snowdec.c index 96221b9802..17c7ccaf2c 100644 --- a/libavcodec/snowdec.c +++ b/libavcodec/snowdec.c @@ -661,7 +661,6 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *picture, int decode_state[MAX_DECOMPOSITIONS][4][1]; /* Stored state info for unpack_coeffs. 1 variable per instance. */ if(s->avctx->debug&2048){ - memset(s->spatial_dwt_buffer, 0, sizeof(DWTELEM)*w*h); predict_plane(s, s->spatial_idwt_buffer, plane_index, 1); for(y=0; y<h; y++){ -- 2.34.1
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/snow.c | 23 +++++++++-------------- libavcodec/snowenc.c | 16 +++++++++++++++- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/libavcodec/snow.c b/libavcodec/snow.c index 7fb1660dd6..7e93005492 100644 --- a/libavcodec/snow.c +++ b/libavcodec/snow.c @@ -456,10 +456,7 @@ av_cold int ff_snow_common_init(AVCodecContext *avctx){ height= s->avctx->height; if (!FF_ALLOCZ_TYPED_ARRAY(s->spatial_idwt_buffer, width * height) || - !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->temp_idwt_buffer, width)) return AVERROR(ENOMEM); for(i=0; i<MAX_REF_FRAMES; i++) { @@ -492,8 +489,7 @@ int ff_snow_common_init_after_header(AVCodecContext *avctx) { size = FFMAX(FFABS(s->mconly_picture->linesize[0]), size); } - if (!(s->scratchbuf = av_calloc(size, 7 * MB_SIZE)) || - !(s->emu_edge_buffer = av_calloc(size, 2 * MB_SIZE + HTAPS_MAX - 1))) + if (!(s->scratchbuf = av_calloc(size, 7 * MB_SIZE))) return AVERROR(ENOMEM); } @@ -517,8 +513,8 @@ int ff_snow_common_init_after_header(AVCodecContext *avctx) { for(level=s->spatial_decomposition_count-1; level>=0; level--){ for(orientation=level ? 1 : 0; orientation<4; orientation++){ SubBand *b= &s->plane[plane_index].band[level][orientation]; + ptrdiff_t offset = 0; - b->buf= s->spatial_dwt_buffer; b->level= level; b->stride= s->plane[plane_index].width << (s->spatial_decomposition_count - level); b->width = (w + !(orientation&1))>>1; @@ -529,17 +525,20 @@ int ff_snow_common_init_after_header(AVCodecContext *avctx) { b->buf_y_offset = 0; if(orientation&1){ - b->buf += (w+1)>>1; + offset += (w + 1) >> 1; b->buf_x_offset = (w+1)>>1; } if(orientation>1){ - b->buf += b->stride>>1; + offset += b->stride >> 1; b->buf_y_offset = b->stride_line >> 1; } - b->ibuf= s->spatial_idwt_buffer + (b->buf - s->spatial_dwt_buffer); + b->ibuf = s->spatial_idwt_buffer + offset; if(level) b->parent= &s->plane[plane_index].band[level-1][orientation]; + if (s->spatial_dwt_buffer) { /* Equivalently: if s is encoder */ + b->buf = s->spatial_dwt_buffer + offset; + } //FIXME avoid this realloc av_freep(&b->x_coeff); b->x_coeff = av_calloc((b->width + 1) * b->height + 1, @@ -601,15 +600,11 @@ av_cold void ff_snow_common_end(SnowContext *s) { int plane_index, level, orientation, i; - av_freep(&s->spatial_dwt_buffer); - av_freep(&s->temp_dwt_buffer); av_freep(&s->spatial_idwt_buffer); av_freep(&s->temp_idwt_buffer); - av_freep(&s->run_buffer); av_freep(&s->block); av_freep(&s->scratchbuf); - av_freep(&s->emu_edge_buffer); for(i=0; i<MAX_REF_FRAMES; i++){ if(s->last_picture[i] && s->last_picture[i]->data[0]) { diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c index fec061a8c5..b8148cbfce 100644 --- a/libavcodec/snowenc.c +++ b/libavcodec/snowenc.c @@ -104,7 +104,7 @@ static inline void put_symbol2(RangeCoder *c, uint8_t *state, int v, int log2) static av_cold int encode_init(AVCodecContext *avctx) { SnowContext *s = avctx->priv_data; - int plane_index, ret; + int plane_index, ret, height, width; int i; if(s->pred == DWT_97 @@ -164,6 +164,16 @@ static av_cold int encode_init(AVCodecContext *avctx) ff_snow_alloc_blocks(s); + width = avctx->width; + height = avctx->height; + if(!FF_ALLOCZ_TYPED_ARRAY(s->spatial_dwt_buffer, width * height) || + !FF_ALLOCZ_TYPED_ARRAY(s->temp_dwt_buffer, width) || + !FF_ALLOCZ_TYPED_ARRAY(s->run_buffer, ((width + 1) >> 1) * ((height + 1) >> 1))) + return AVERROR(ENOMEM); + s->emu_edge_buffer = av_calloc(width + 128U, 2 * (2 * MB_SIZE + HTAPS_MAX - 1)); + if (!s->emu_edge_buffer) + return AVERROR(ENOMEM); + s->version=0; s->m.avctx = avctx; @@ -1986,6 +1996,10 @@ static av_cold int encode_end(AVCodecContext *avctx) ff_snow_common_end(s); ff_rate_control_uninit(&s->m); av_frame_free(&s->input_picture); + av_freep(&s->emu_edge_buffer); + av_freep(&s->spatial_dwt_buffer); + av_freep(&s->temp_dwt_buffer); + av_freep(&s->run_buffer); for (int i = 0; i < MAX_REF_FRAMES; i++) { av_freep(&s->ref_mvs[i]); -- 2.34.1
On Mon, Oct 10, 2022 at 05:13:06AM +0200, Andreas Rheinhardt wrote:
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/snow.c | 23 +++++++++-------------- libavcodec/snowenc.c | 16 +++++++++++++++- 2 files changed, 24 insertions(+), 15 deletions(-)
probably ok [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Many things microsoft did are stupid, but not doing something just because microsoft did it is even more stupid. If everything ms did were stupid they would be bankrupt already.
It comes from a time before frames were refcounted; it has indeed been added in a follow-up commit to c13e490dce1a66d79e1f053d8a38fb9b2eb53267: "codec_release_buffer: fix handling of non user buffers". This type of check is obsolete now. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/snow.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/libavcodec/snow.c b/libavcodec/snow.c index 7e93005492..dcd6d67ad5 100644 --- a/libavcodec/snow.c +++ b/libavcodec/snow.c @@ -607,9 +607,6 @@ av_cold void ff_snow_common_end(SnowContext *s) av_freep(&s->scratchbuf); for(i=0; i<MAX_REF_FRAMES; i++){ - if(s->last_picture[i] && s->last_picture[i]->data[0]) { - av_assert0(s->last_picture[i]->data[0] != s->current_picture->data[0]); - } av_frame_free(&s->last_picture[i]); } -- 2.34.1
Andreas Rheinhardt:
It comes from a time before frames were refcounted; it has indeed been added in a follow-up commit to c13e490dce1a66d79e1f053d8a38fb9b2eb53267: "codec_release_buffer: fix handling of non user buffers". This type of check is obsolete now.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/snow.c | 3 --- 1 file changed, 3 deletions(-)
diff --git a/libavcodec/snow.c b/libavcodec/snow.c index 7e93005492..dcd6d67ad5 100644 --- a/libavcodec/snow.c +++ b/libavcodec/snow.c @@ -607,9 +607,6 @@ av_cold void ff_snow_common_end(SnowContext *s) av_freep(&s->scratchbuf);
for(i=0; i<MAX_REF_FRAMES; i++){ - if(s->last_picture[i] && s->last_picture[i]->data[0]) { - av_assert0(s->last_picture[i]->data[0] != s->current_picture->data[0]); - } av_frame_free(&s->last_picture[i]); }
Will apply this patch tomorrow unless there are objections. - Andreas
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/snow.c | 17 +++-------------- libavcodec/snowdec.c | 9 +++++++++ 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/libavcodec/snow.c b/libavcodec/snow.c index dcd6d67ad5..52ab39bfd4 100644 --- a/libavcodec/snow.c +++ b/libavcodec/snow.c @@ -538,13 +538,14 @@ int ff_snow_common_init_after_header(AVCodecContext *avctx) { b->parent= &s->plane[plane_index].band[level-1][orientation]; if (s->spatial_dwt_buffer) { /* Equivalently: if s is encoder */ b->buf = s->spatial_dwt_buffer + offset; - } + } else { //FIXME avoid this realloc av_freep(&b->x_coeff); b->x_coeff = av_calloc((b->width + 1) * b->height + 1, sizeof(*b->x_coeff)); if (!b->x_coeff) return AVERROR(ENOMEM); + } } w= (w+1)>>1; h= (h+1)>>1; @@ -598,26 +599,14 @@ int ff_snow_frame_start(SnowContext *s){ av_cold void ff_snow_common_end(SnowContext *s) { - int plane_index, level, orientation, i; - av_freep(&s->spatial_idwt_buffer); av_freep(&s->temp_idwt_buffer); av_freep(&s->block); av_freep(&s->scratchbuf); - for(i=0; i<MAX_REF_FRAMES; i++){ + for (int i = 0; i < MAX_REF_FRAMES; i++) av_frame_free(&s->last_picture[i]); - } - - for(plane_index=0; plane_index < MAX_PLANES; plane_index++){ - for(level=MAX_DECOMPOSITIONS-1; level>=0; level--){ - for(orientation=level ? 1 : 0; orientation<4; orientation++){ - SubBand *b= &s->plane[plane_index].band[level][orientation]; - av_freep(&b->x_coeff); - } - } - } av_frame_free(&s->current_picture); } diff --git a/libavcodec/snowdec.c b/libavcodec/snowdec.c index 17c7ccaf2c..13948398b0 100644 --- a/libavcodec/snowdec.c +++ b/libavcodec/snowdec.c @@ -793,6 +793,15 @@ static av_cold int decode_end(AVCodecContext *avctx) ff_snow_common_end(s); + for (int plane_index = 0; plane_index < MAX_PLANES; plane_index++){ + for (int level = MAX_DECOMPOSITIONS - 1; level >= 0; level--) { + for (int orientation = level ? 1 : 0; orientation < 4; orientation++){ + SubBand *b = &s->plane[plane_index].band[level][orientation]; + + av_freep(&b->x_coeff); + } + } + } av_frame_free(&s->mconly_picture); s->avmv_size = 0; -- 2.34.1
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/snow.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libavcodec/snow.c b/libavcodec/snow.c index 52ab39bfd4..ca43550f20 100644 --- a/libavcodec/snow.c +++ b/libavcodec/snow.c @@ -539,12 +539,12 @@ int ff_snow_common_init_after_header(AVCodecContext *avctx) { if (s->spatial_dwt_buffer) { /* Equivalently: if s is encoder */ b->buf = s->spatial_dwt_buffer + offset; } else { - //FIXME avoid this realloc - av_freep(&b->x_coeff); - b->x_coeff = av_calloc((b->width + 1) * b->height + 1, - sizeof(*b->x_coeff)); - if (!b->x_coeff) - return AVERROR(ENOMEM); + //FIXME avoid this realloc + av_freep(&b->x_coeff); + b->x_coeff = av_calloc((b->width + 1) * b->height + 1, + sizeof(*b->x_coeff)); + if (!b->x_coeff) + return AVERROR(ENOMEM); } } w= (w+1)>>1; -- 2.34.1
The Snow decoder checks two bits of AVCodecContext.debug via numerical constants, not defines. One of these constants (512) used to be equivalent to FF_DEBUG_PTS which has been removed in 302554835e39b79b977ed60c9afe81b44590dfef (merged in 6e69525e6984d51165de0b17b796bbc29f9dd6e7). It is unlikely that 512 was intended to be FF_DEBUG_PTS, as it has nothing do to with PTS; instead it makes certain parts of the code behave like it does for keyframes even if the current frame is not a keyframe. Whatever it might have been intended for, it is almost certainly unused now. This commit therefore removes said checks. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- Actually, I'd like to remove the other debug code (debug&2048), too; this would entail removing the mconly_picture, yet I wonder about the size of scratchbuf: Before a4ce3706595edd9b537861f0e5447e31babf2100 it's size was affected by the linesize of mconly_picture for encoders, too. Is it possible that these codecs are built on the assumption that the linesize of all frames stays the same if the dimensions stay the same, so that simply removing mconly_picture would leave scratchbuf too small? (Of course I am aware that the pixel format check would need that is currently performed with mconly_picture would need to be replaced by something similar. That should be easy.) libavcodec/snow.h | 2 +- libavcodec/snowdec.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/snow.h b/libavcodec/snow.h index 8da3d99885..0c59fb7ec4 100644 --- a/libavcodec/snow.h +++ b/libavcodec/snow.h @@ -418,7 +418,7 @@ static av_always_inline void predict_slice(SnowContext *s, IDWTELEM *buf, int pl int w= p->width; int h= p->height; av_assert2(s->chroma_h_shift == s->chroma_v_shift); // obmc params assume squares - if(s->keyframe || (s->avctx->debug&512)){ + if (s->keyframe) { if(mb_y==mb_h) return; diff --git a/libavcodec/snowdec.c b/libavcodec/snowdec.c index 13948398b0..60eb9a7f52 100644 --- a/libavcodec/snowdec.c +++ b/libavcodec/snowdec.c @@ -191,7 +191,7 @@ static av_always_inline void predict_slice_buffered(SnowContext *s, slice_buffer int w= p->width; int h= p->height; - if(s->keyframe || (s->avctx->debug&512)){ + if (s->keyframe) { if(mb_y==mb_h) return; @@ -694,7 +694,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *picture, int slice_starty = block_h*mb_y; int slice_h = block_h*(mb_y+1); - if (!(s->keyframe || s->avctx->debug&512)){ + if (!s->keyframe) { slice_starty = FFMAX(0, slice_starty - (block_h >> 1)); slice_h -= (block_h >> 1); } @@ -709,7 +709,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *picture, const int extra= 3; start_y = (mb_y ? ((block_h * our_mb_start) >> (s->spatial_decomposition_count - level)) + s->spatial_decomposition_count - level + extra: 0); end_y = (((block_h * our_mb_end) >> (s->spatial_decomposition_count - level)) + s->spatial_decomposition_count - level + extra); - if (!(s->keyframe || s->avctx->debug&512)){ + if (!s->keyframe) { start_y = FFMAX(0, start_y - (block_h >> (1+s->spatial_decomposition_count - level))); end_y = FFMAX(0, end_y - (block_h >> (1+s->spatial_decomposition_count - level))); } -- 2.34.1
On Mon, Oct 10, 2022 at 05:13:10AM +0200, Andreas Rheinhardt wrote:
The Snow decoder checks two bits of AVCodecContext.debug via numerical constants, not defines. One of these constants (512) used to be equivalent to FF_DEBUG_PTS which has been removed in 302554835e39b79b977ed60c9afe81b44590dfef (merged in 6e69525e6984d51165de0b17b796bbc29f9dd6e7).
It is unlikely that 512 was intended to be FF_DEBUG_PTS, as it has nothing do to with PTS; instead it makes certain parts of the code behave like it does for keyframes even if the current frame is not a keyframe.
why not fix it instead of removing ? you can check what it did by looking at the code when it was added. thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I have never wished to cater to the crowd; for what I know they do not approve, and what they approve I do not know. -- Epicurus
Andreas Rheinhardt:
rtjpeg is a mode of nuv and not a decoder in its own right.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- configure | 1 - 1 file changed, 1 deletion(-)
diff --git a/configure b/configure index ab6ff27249..2c4f5043d5 100755 --- a/configure +++ b/configure @@ -2934,7 +2934,6 @@ ralf_decoder_select="golomb" rasc_decoder_select="inflate_wrapper" rawvideo_decoder_select="bswapdsp" rscc_decoder_deps="zlib" -rtjpeg_decoder_select="me_cmp" rv10_decoder_select="h263_decoder" rv10_encoder_select="h263_encoder" rv20_decoder_select="h263_decoder"
Will apply the first nine patches of this tomorrow unless there are objections. - Andreas
participants (2)
-
Andreas Rheinhardt -
Michael Niedermayer