* [FFmpeg-devel] [PATCH v2 2/3] avfilter/vf_uspp: add AV_CODEC_FLAG_RECON_FRAME support
2023-03-19 19:42 [FFmpeg-devel] [PATCH v2 1/3] avcodec/snowenc: AV_CODEC_CAP_ENCODER_RECON_FRAME support Michael Niedermayer
@ 2023-03-19 19:42 ` Michael Niedermayer
2023-03-19 19:42 ` [FFmpeg-devel] [PATCH v2 3/3] avfilter/vf_mcdeint: update to new API Michael Niedermayer
2023-03-20 22:07 ` [FFmpeg-devel] [PATCH v2 1/3] avcodec/snowenc: AV_CODEC_CAP_ENCODER_RECON_FRAME support James Almer
2 siblings, 0 replies; 8+ messages in thread
From: Michael Niedermayer @ 2023-03-19 19:42 UTC (permalink / raw)
To: FFmpeg development discussions and patches
about 50% faster (based on command line fps)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
libavfilter/vf_uspp.c | 53 +++++++++++++++++++++++++++----------------
1 file changed, 34 insertions(+), 19 deletions(-)
diff --git a/libavfilter/vf_uspp.c b/libavfilter/vf_uspp.c
index f60eb230a2..ffdaa907b2 100644
--- a/libavfilter/vf_uspp.c
+++ b/libavfilter/vf_uspp.c
@@ -231,16 +231,25 @@ static int filter_1phase(AVFilterContext *ctx, void *arg, int i, int nb_jobs)
return ret;
}
- ret = avcodec_send_packet(p->avctx_dec[i], pkt);
- av_packet_unref(pkt);
- if (ret < 0) {
- av_log(p->avctx_dec[i], AV_LOG_ERROR, "Error sending a packet for decoding\n");
- return ret;
- }
- ret = avcodec_receive_frame(p->avctx_dec[i], p->frame_dec[i]);
- if (ret < 0) {
- av_log(p->avctx_dec[i], AV_LOG_ERROR, "Error receiving a frame from decoding\n");
- return ret;
+ if (p->avctx_enc[i]->flags & AV_CODEC_FLAG_RECON_FRAME) {
+ av_packet_unref(pkt);
+ ret = avcodec_receive_frame(p->avctx_enc[i], p->frame_dec[i]);
+ if (ret < 0) {
+ av_log(p->avctx_dec[i], AV_LOG_ERROR, "Error receiving a frame from encoding\n");
+ return ret;
+ }
+ } else {
+ ret = avcodec_send_packet(p->avctx_dec[i], pkt);
+ av_packet_unref(pkt);
+ if (ret < 0) {
+ av_log(p->avctx_dec[i], AV_LOG_ERROR, "Error sending a packet for decoding\n");
+ return ret;
+ }
+ ret = avcodec_receive_frame(p->avctx_dec[i], p->frame_dec[i]);
+ if (ret < 0) {
+ av_log(p->avctx_dec[i], AV_LOG_ERROR, "Error receiving a frame from decoding\n");
+ return ret;
+ }
}
offset = (BLOCK-x1) + (BLOCK-y1) * p->frame_dec[i]->linesize[0];
@@ -383,23 +392,21 @@ static int config_input(AVFilterLink *inlink)
if (!(uspp->avctx_enc[i] = avcodec_alloc_context3(NULL)))
return AVERROR(ENOMEM);
- if (!(uspp->avctx_dec[i] = avcodec_alloc_context3(NULL)))
- return AVERROR(ENOMEM);
avctx_enc = uspp->avctx_enc[i];
- avctx_dec = uspp->avctx_dec[i];
- avctx_dec->width =
avctx_enc->width = width + BLOCK;
- avctx_dec->height =
avctx_enc->height = height + BLOCK;
avctx_enc->time_base = (AVRational){1,25}; // meaningless
avctx_enc->gop_size = INT_MAX;
avctx_enc->max_b_frames = 0;
avctx_enc->pix_fmt = inlink->format;
avctx_enc->flags = AV_CODEC_FLAG_QSCALE | AV_CODEC_FLAG_LOW_DELAY;
+ if (enc->capabilities & AV_CODEC_CAP_ENCODER_RECON_FRAME) {
+ avctx_enc->flags |= AV_CODEC_FLAG_RECON_FRAME;
+ av_dict_set(&opts, "no_bitstream", "1", 0);
+ }
avctx_enc->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL;
avctx_enc->global_quality = 123;
- avctx_dec->thread_count =
avctx_enc->thread_count = 1; // We do threading in the filter with muiltiple codecs
ret = avcodec_open2(avctx_enc, enc, &opts);
av_dict_free(&opts);
@@ -408,9 +415,17 @@ static int config_input(AVFilterLink *inlink)
av_assert0(avctx_enc->codec);
- ret = avcodec_open2(avctx_dec, dec, NULL);
- if (ret < 0)
- return ret;
+ if (!(enc->capabilities & AV_CODEC_CAP_ENCODER_RECON_FRAME)) {
+ if (!(uspp->avctx_dec[i] = avcodec_alloc_context3(NULL)))
+ return AVERROR(ENOMEM);
+ avctx_dec = uspp->avctx_dec[i];
+ avctx_dec->width = avctx_enc->width;
+ avctx_dec->height = avctx_enc->height;
+ avctx_dec->thread_count = 1;
+ ret = avcodec_open2(avctx_dec, dec, NULL);
+ if (ret < 0)
+ return ret;
+ }
if (!(uspp->frame[i] = av_frame_alloc()))
return AVERROR(ENOMEM);
--
2.17.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 8+ messages in thread
* [FFmpeg-devel] [PATCH v2 3/3] avfilter/vf_mcdeint: update to new API
2023-03-19 19:42 [FFmpeg-devel] [PATCH v2 1/3] avcodec/snowenc: AV_CODEC_CAP_ENCODER_RECON_FRAME support Michael Niedermayer
2023-03-19 19:42 ` [FFmpeg-devel] [PATCH v2 2/3] avfilter/vf_uspp: add AV_CODEC_FLAG_RECON_FRAME support Michael Niedermayer
@ 2023-03-19 19:42 ` Michael Niedermayer
2023-03-20 22:07 ` [FFmpeg-devel] [PATCH v2 1/3] avcodec/snowenc: AV_CODEC_CAP_ENCODER_RECON_FRAME support James Almer
2 siblings, 0 replies; 8+ messages in thread
From: Michael Niedermayer @ 2023-03-19 19:42 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
configure | 5 -----
doc/filters.texi | 2 --
libavfilter/vf_mcdeint.c | 30 +++++++++++++++++++++++-------
3 files changed, 23 insertions(+), 14 deletions(-)
diff --git a/configure b/configure
index 0370e25577..07b94e5e7c 100755
--- a/configure
+++ b/configure
@@ -7355,11 +7355,6 @@ esac
enable frame_thread_encoder
-# these filters depend on removed avcodec APIs
-# they are kept disabled for now, but will be removed if
-# nobody updates and re-enables them
-disable mcdeint_filter
-
enabled asm || { arch=c; disable $ARCH_LIST $ARCH_EXT_LIST; }
check_deps $CONFIG_LIST \
diff --git a/doc/filters.texi b/doc/filters.texi
index d634924bfb..59c1faa0b4 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -16988,8 +16988,6 @@ Apply motion-compensation deinterlacing.
It needs one field per frame as input and must thus be used together
with yadif=1/3 or equivalent.
-This filter is only available in ffmpeg version 4.4 or earlier.
-
This filter accepts the following options:
@table @option
@item mode
diff --git a/libavfilter/vf_mcdeint.c b/libavfilter/vf_mcdeint.c
index e747521c0a..a2c3e79b9e 100644
--- a/libavfilter/vf_mcdeint.c
+++ b/libavfilter/vf_mcdeint.c
@@ -75,6 +75,7 @@ typedef struct MCDeintContext {
int parity; ///< MCDeintParity
int qp;
AVPacket *pkt;
+ AVFrame *frame_dec;
AVCodecContext *enc_ctx;
} MCDeintContext;
@@ -116,6 +117,9 @@ static int config_props(AVFilterLink *inlink)
mcdeint->pkt = av_packet_alloc();
if (!mcdeint->pkt)
return AVERROR(ENOMEM);
+ mcdeint->frame_dec = av_frame_alloc();
+ if (!mcdeint->frame_dec)
+ return AVERROR(ENOMEM);
mcdeint->enc_ctx = avcodec_alloc_context3(enc);
if (!mcdeint->enc_ctx)
return AVERROR(ENOMEM);
@@ -126,7 +130,7 @@ static int config_props(AVFilterLink *inlink)
enc_ctx->gop_size = INT_MAX;
enc_ctx->max_b_frames = 0;
enc_ctx->pix_fmt = AV_PIX_FMT_YUV420P;
- enc_ctx->flags = AV_CODEC_FLAG_QSCALE | AV_CODEC_FLAG_LOW_DELAY;
+ enc_ctx->flags = AV_CODEC_FLAG_QSCALE | AV_CODEC_FLAG_LOW_DELAY | AV_CODEC_FLAG_RECON_FRAME;
enc_ctx->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL;
enc_ctx->global_quality = 1;
enc_ctx->me_cmp = enc_ctx->me_sub_cmp = FF_CMP_SAD;
@@ -160,15 +164,16 @@ static av_cold void uninit(AVFilterContext *ctx)
av_packet_free(&mcdeint->pkt);
avcodec_free_context(&mcdeint->enc_ctx);
+ av_frame_free(&mcdeint->frame_dec);
}
static int filter_frame(AVFilterLink *inlink, AVFrame *inpic)
{
MCDeintContext *mcdeint = inlink->dst->priv;
AVFilterLink *outlink = inlink->dst->outputs[0];
- AVFrame *outpic, *frame_dec;
+ AVFrame *outpic, *frame_dec = mcdeint->frame_dec;
AVPacket *pkt = mcdeint->pkt;
- int x, y, i, ret, got_frame = 0;
+ int x, y, i, ret;
outpic = ff_get_video_buffer(outlink, outlink->w, outlink->h);
if (!outpic) {
@@ -178,11 +183,22 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpic)
av_frame_copy_props(outpic, inpic);
inpic->quality = mcdeint->qp * FF_QP2LAMBDA;
- ret = avcodec_encode_video2(mcdeint->enc_ctx, pkt, inpic, &got_frame);
- if (ret < 0)
+ ret = avcodec_send_frame(mcdeint->enc_ctx, inpic);
+ if (ret < 0) {
+ av_log(mcdeint->enc_ctx, AV_LOG_ERROR, "Error sending a frame for encoding\n");
goto end;
-
- frame_dec = mcdeint->enc_ctx->coded_frame;
+ }
+ ret = avcodec_receive_packet(mcdeint->enc_ctx, pkt);
+ if (ret < 0) {
+ av_log(mcdeint->enc_ctx, AV_LOG_ERROR, "Error receiving a packet from encoding\n");
+ goto end;
+ }
+ av_packet_unref(pkt);
+ ret = avcodec_receive_frame(mcdeint->enc_ctx, frame_dec);
+ if (ret < 0) {
+ av_log(mcdeint->enc_ctx, AV_LOG_ERROR, "Error receiving a frame from encoding\n");
+ goto end;
+ }
for (i = 0; i < 3; i++) {
int is_chroma = !!i;
--
2.17.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 1/3] avcodec/snowenc: AV_CODEC_CAP_ENCODER_RECON_FRAME support
2023-03-19 19:42 [FFmpeg-devel] [PATCH v2 1/3] avcodec/snowenc: AV_CODEC_CAP_ENCODER_RECON_FRAME support Michael Niedermayer
2023-03-19 19:42 ` [FFmpeg-devel] [PATCH v2 2/3] avfilter/vf_uspp: add AV_CODEC_FLAG_RECON_FRAME support Michael Niedermayer
2023-03-19 19:42 ` [FFmpeg-devel] [PATCH v2 3/3] avfilter/vf_mcdeint: update to new API Michael Niedermayer
@ 2023-03-20 22:07 ` James Almer
2023-03-23 9:50 ` Michael Niedermayer
2 siblings, 1 reply; 8+ messages in thread
From: James Almer @ 2023-03-20 22:07 UTC (permalink / raw)
To: ffmpeg-devel
On 3/19/2023 4:42 PM, Michael Niedermayer wrote:
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
> libavcodec/snowenc.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c
> index 658684c575..5fb5906ed8 100644
> --- a/libavcodec/snowenc.c
> +++ b/libavcodec/snowenc.c
> @@ -26,6 +26,7 @@
> #include "avcodec.h"
> #include "codec_internal.h"
> #include "encode.h"
> +#include "internal.h" //For AVCodecInternal.recon_frame
> #include "me_cmp.h"
> #include "packet_internal.h"
> #include "snow_dwt.h"
> @@ -1576,6 +1577,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
> {
> SnowContext *s = avctx->priv_data;
> RangeCoder * const c= &s->c;
> + AVCodecInternal *avci = avctx->internal;
> AVFrame *pic;
> const int width= s->avctx->width;
> const int height= s->avctx->height;
> @@ -1877,6 +1879,10 @@ redo_frame:
> s->encoding_error,
> (s->avctx->flags&AV_CODEC_FLAG_PSNR) ? SNOW_MAX_PLANES : 0,
> s->current_picture->pict_type);
> + if (s->avctx->flags & AV_CODEC_FLAG_RECON_FRAME) {
> + av_frame_unref(avci->recon_frame);
> + av_frame_ref(avci->recon_frame, s->current_picture);
> + }
>
> pkt->size = ff_rac_terminate(c, 0);
> if (s->current_picture->key_frame)
> @@ -1934,7 +1940,9 @@ const FFCodec ff_snow_encoder = {
> CODEC_LONG_NAME("Snow"),
> .p.type = AVMEDIA_TYPE_VIDEO,
> .p.id = AV_CODEC_ID_SNOW,
> - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
> + .p.capabilities = AV_CODEC_CAP_DR1 |
> + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE |
> + AV_CODEC_CAP_ENCODER_RECON_FRAME,
> .priv_data_size = sizeof(SnowContext),
> .init = encode_init,
> FF_CODEC_ENCODE_CB(encode_frame),
Testing with the tool from
https://git.khirnov.net/libav.git/commit/?h=recon&id=d78e17840347abfe10b2bc7e789c60665de56e1f
(Which i hope will be upstreamed eventually) i get
$ tools/enc_recon_frame_test input.y4m snow flags=+bitexact 10
Checksum mismatch in frame ts=0, plane 0
I don't know if this really matters for snow (is it mean to be
bitexact?), but it seems the very first frame returned by the
reconstructed frame API is not the same as the one output by the snow
decoder. The rest seem to match, though.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 1/3] avcodec/snowenc: AV_CODEC_CAP_ENCODER_RECON_FRAME support
2023-03-20 22:07 ` [FFmpeg-devel] [PATCH v2 1/3] avcodec/snowenc: AV_CODEC_CAP_ENCODER_RECON_FRAME support James Almer
@ 2023-03-23 9:50 ` Michael Niedermayer
2023-03-23 11:32 ` James Almer
0 siblings, 1 reply; 8+ messages in thread
From: Michael Niedermayer @ 2023-03-23 9:50 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1.1: Type: text/plain, Size: 3453 bytes --]
On Mon, Mar 20, 2023 at 07:07:59PM -0300, James Almer wrote:
> On 3/19/2023 4:42 PM, Michael Niedermayer wrote:
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> > libavcodec/snowenc.c | 10 +++++++++-
> > 1 file changed, 9 insertions(+), 1 deletion(-)
> >
> > diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c
> > index 658684c575..5fb5906ed8 100644
> > --- a/libavcodec/snowenc.c
> > +++ b/libavcodec/snowenc.c
> > @@ -26,6 +26,7 @@
> > #include "avcodec.h"
> > #include "codec_internal.h"
> > #include "encode.h"
> > +#include "internal.h" //For AVCodecInternal.recon_frame
> > #include "me_cmp.h"
> > #include "packet_internal.h"
> > #include "snow_dwt.h"
> > @@ -1576,6 +1577,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
> > {
> > SnowContext *s = avctx->priv_data;
> > RangeCoder * const c= &s->c;
> > + AVCodecInternal *avci = avctx->internal;
> > AVFrame *pic;
> > const int width= s->avctx->width;
> > const int height= s->avctx->height;
> > @@ -1877,6 +1879,10 @@ redo_frame:
> > s->encoding_error,
> > (s->avctx->flags&AV_CODEC_FLAG_PSNR) ? SNOW_MAX_PLANES : 0,
> > s->current_picture->pict_type);
> > + if (s->avctx->flags & AV_CODEC_FLAG_RECON_FRAME) {
> > + av_frame_unref(avci->recon_frame);
> > + av_frame_ref(avci->recon_frame, s->current_picture);
> > + }
> > pkt->size = ff_rac_terminate(c, 0);
> > if (s->current_picture->key_frame)
> > @@ -1934,7 +1940,9 @@ const FFCodec ff_snow_encoder = {
> > CODEC_LONG_NAME("Snow"),
> > .p.type = AVMEDIA_TYPE_VIDEO,
> > .p.id = AV_CODEC_ID_SNOW,
> > - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
> > + .p.capabilities = AV_CODEC_CAP_DR1 |
> > + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE |
> > + AV_CODEC_CAP_ENCODER_RECON_FRAME,
> > .priv_data_size = sizeof(SnowContext),
> > .init = encode_init,
> > FF_CODEC_ENCODE_CB(encode_frame),
>
> Testing with the tool from https://git.khirnov.net/libav.git/commit/?h=recon&id=d78e17840347abfe10b2bc7e789c60665de56e1f
> (Which i hope will be upstreamed eventually) i get
>
> $ tools/enc_recon_frame_test input.y4m snow flags=+bitexact 10
> Checksum mismatch in frame ts=0, plane 0
I cannot replicate this, using matrixbench and above command line i get no
mismatches, where can i find the input.y4m you used ?
also would be nice if this tool would write a image showing the difference
thx
>
> I don't know if this really matters for snow (is it mean to be bitexact?),
> but it seems the very first frame returned by the reconstructed frame API is
> not the same as the one output by the snow decoder. The rest seem to match,
> though.
This sounds rather strange, the first frame would be used as reference for
motion compensation so the subsequent frames matching after a mismatch is
"surprising"
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Concerning the gods, I have no means of knowing whether they exist or not
or of what sort they may be, because of the obscurity of the subject, and
the brevity of human life -- Protagoras
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
[-- Attachment #2: Type: text/plain, Size: 251 bytes --]
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 1/3] avcodec/snowenc: AV_CODEC_CAP_ENCODER_RECON_FRAME support
2023-03-23 9:50 ` Michael Niedermayer
@ 2023-03-23 11:32 ` James Almer
2023-03-24 0:08 ` Michael Niedermayer
0 siblings, 1 reply; 8+ messages in thread
From: James Almer @ 2023-03-23 11:32 UTC (permalink / raw)
To: ffmpeg-devel
On 3/23/2023 6:50 AM, Michael Niedermayer wrote:
> On Mon, Mar 20, 2023 at 07:07:59PM -0300, James Almer wrote:
>> On 3/19/2023 4:42 PM, Michael Niedermayer wrote:
>>> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
>>> ---
>>> libavcodec/snowenc.c | 10 +++++++++-
>>> 1 file changed, 9 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c
>>> index 658684c575..5fb5906ed8 100644
>>> --- a/libavcodec/snowenc.c
>>> +++ b/libavcodec/snowenc.c
>>> @@ -26,6 +26,7 @@
>>> #include "avcodec.h"
>>> #include "codec_internal.h"
>>> #include "encode.h"
>>> +#include "internal.h" //For AVCodecInternal.recon_frame
>>> #include "me_cmp.h"
>>> #include "packet_internal.h"
>>> #include "snow_dwt.h"
>>> @@ -1576,6 +1577,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
>>> {
>>> SnowContext *s = avctx->priv_data;
>>> RangeCoder * const c= &s->c;
>>> + AVCodecInternal *avci = avctx->internal;
>>> AVFrame *pic;
>>> const int width= s->avctx->width;
>>> const int height= s->avctx->height;
>>> @@ -1877,6 +1879,10 @@ redo_frame:
>>> s->encoding_error,
>>> (s->avctx->flags&AV_CODEC_FLAG_PSNR) ? SNOW_MAX_PLANES : 0,
>>> s->current_picture->pict_type);
>>> + if (s->avctx->flags & AV_CODEC_FLAG_RECON_FRAME) {
>>> + av_frame_unref(avci->recon_frame);
>>> + av_frame_ref(avci->recon_frame, s->current_picture);
>>> + }
>>> pkt->size = ff_rac_terminate(c, 0);
>>> if (s->current_picture->key_frame)
>>> @@ -1934,7 +1940,9 @@ const FFCodec ff_snow_encoder = {
>>> CODEC_LONG_NAME("Snow"),
>>> .p.type = AVMEDIA_TYPE_VIDEO,
>>> .p.id = AV_CODEC_ID_SNOW,
>>> - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
>>> + .p.capabilities = AV_CODEC_CAP_DR1 |
>>> + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE |
>>> + AV_CODEC_CAP_ENCODER_RECON_FRAME,
>>> .priv_data_size = sizeof(SnowContext),
>>> .init = encode_init,
>>> FF_CODEC_ENCODE_CB(encode_frame),
>>
>> Testing with the tool from https://git.khirnov.net/libav.git/commit/?h=recon&id=d78e17840347abfe10b2bc7e789c60665de56e1f
>> (Which i hope will be upstreamed eventually) i get
>>
>> $ tools/enc_recon_frame_test input.y4m snow flags=+bitexact 10
>> Checksum mismatch in frame ts=0, plane 0
>
> I cannot replicate this, using matrixbench and above command line i get no
> mismatches, where can i find the input.y4m you used ?
It was https://0x0.st/sfRh.y4m
>
> also would be nice if this tool would write a image showing the difference
>
> thx
>
>>
>> I don't know if this really matters for snow (is it mean to be bitexact?),
>> but it seems the very first frame returned by the reconstructed frame API is
>> not the same as the one output by the snow decoder. The rest seem to match,
>> though.
>
> This sounds rather strange, the first frame would be used as reference for
> motion compensation so the subsequent frames matching after a mismatch is
> "surprising"
I tried other supported encoders like libx264 and librav1e and none of
them report mismatches.
>
> thx
>
> [...]
>
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 1/3] avcodec/snowenc: AV_CODEC_CAP_ENCODER_RECON_FRAME support
2023-03-23 11:32 ` James Almer
@ 2023-03-24 0:08 ` Michael Niedermayer
2023-03-25 20:56 ` Michael Niedermayer
0 siblings, 1 reply; 8+ messages in thread
From: Michael Niedermayer @ 2023-03-24 0:08 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1.1: Type: text/plain, Size: 4225 bytes --]
On Thu, Mar 23, 2023 at 08:32:48AM -0300, James Almer wrote:
> On 3/23/2023 6:50 AM, Michael Niedermayer wrote:
> > On Mon, Mar 20, 2023 at 07:07:59PM -0300, James Almer wrote:
> > > On 3/19/2023 4:42 PM, Michael Niedermayer wrote:
> > > > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > > > ---
> > > > libavcodec/snowenc.c | 10 +++++++++-
> > > > 1 file changed, 9 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c
> > > > index 658684c575..5fb5906ed8 100644
> > > > --- a/libavcodec/snowenc.c
> > > > +++ b/libavcodec/snowenc.c
> > > > @@ -26,6 +26,7 @@
> > > > #include "avcodec.h"
> > > > #include "codec_internal.h"
> > > > #include "encode.h"
> > > > +#include "internal.h" //For AVCodecInternal.recon_frame
> > > > #include "me_cmp.h"
> > > > #include "packet_internal.h"
> > > > #include "snow_dwt.h"
> > > > @@ -1576,6 +1577,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
> > > > {
> > > > SnowContext *s = avctx->priv_data;
> > > > RangeCoder * const c= &s->c;
> > > > + AVCodecInternal *avci = avctx->internal;
> > > > AVFrame *pic;
> > > > const int width= s->avctx->width;
> > > > const int height= s->avctx->height;
> > > > @@ -1877,6 +1879,10 @@ redo_frame:
> > > > s->encoding_error,
> > > > (s->avctx->flags&AV_CODEC_FLAG_PSNR) ? SNOW_MAX_PLANES : 0,
> > > > s->current_picture->pict_type);
> > > > + if (s->avctx->flags & AV_CODEC_FLAG_RECON_FRAME) {
> > > > + av_frame_unref(avci->recon_frame);
> > > > + av_frame_ref(avci->recon_frame, s->current_picture);
> > > > + }
> > > > pkt->size = ff_rac_terminate(c, 0);
> > > > if (s->current_picture->key_frame)
> > > > @@ -1934,7 +1940,9 @@ const FFCodec ff_snow_encoder = {
> > > > CODEC_LONG_NAME("Snow"),
> > > > .p.type = AVMEDIA_TYPE_VIDEO,
> > > > .p.id = AV_CODEC_ID_SNOW,
> > > > - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
> > > > + .p.capabilities = AV_CODEC_CAP_DR1 |
> > > > + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE |
> > > > + AV_CODEC_CAP_ENCODER_RECON_FRAME,
> > > > .priv_data_size = sizeof(SnowContext),
> > > > .init = encode_init,
> > > > FF_CODEC_ENCODE_CB(encode_frame),
> > >
> > > Testing with the tool from https://git.khirnov.net/libav.git/commit/?h=recon&id=d78e17840347abfe10b2bc7e789c60665de56e1f
> > > (Which i hope will be upstreamed eventually) i get
> > >
> > > $ tools/enc_recon_frame_test input.y4m snow flags=+bitexact 10
> > > Checksum mismatch in frame ts=0, plane 0
> >
> > I cannot replicate this, using matrixbench and above command line i get no
> > mismatches, where can i find the input.y4m you used ?
>
> It was https://0x0.st/sfRh.y4m
>
> >
> > also would be nice if this tool would write a image showing the difference
> >
> > thx
> >
> > >
> > > I don't know if this really matters for snow (is it mean to be bitexact?),
> > > but it seems the very first frame returned by the reconstructed frame API is
> > > not the same as the one output by the snow decoder. The rest seem to match,
> > > though.
> >
> > This sounds rather strange, the first frame would be used as reference for
> > motion compensation so the subsequent frames matching after a mismatch is
> > "surprising"
>
> I tried other supported encoders like libx264 and librav1e and none of them
> report mismatches.
bugs
ill send a patchset
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Modern terrorism, a quick summary: Need oil, start war with country that
has oil, kill hundread thousand in war. Let country fall into chaos,
be surprised about raise of fundamantalists. Drop more bombs, kill more
people, be surprised about them taking revenge and drop even more bombs
and strip your own citizens of their rights and freedoms. to be continued
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
[-- Attachment #2: Type: text/plain, Size: 251 bytes --]
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 1/3] avcodec/snowenc: AV_CODEC_CAP_ENCODER_RECON_FRAME support
2023-03-24 0:08 ` Michael Niedermayer
@ 2023-03-25 20:56 ` Michael Niedermayer
0 siblings, 0 replies; 8+ messages in thread
From: Michael Niedermayer @ 2023-03-25 20:56 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1.1: Type: text/plain, Size: 4266 bytes --]
On Fri, Mar 24, 2023 at 01:08:56AM +0100, Michael Niedermayer wrote:
> On Thu, Mar 23, 2023 at 08:32:48AM -0300, James Almer wrote:
> > On 3/23/2023 6:50 AM, Michael Niedermayer wrote:
> > > On Mon, Mar 20, 2023 at 07:07:59PM -0300, James Almer wrote:
> > > > On 3/19/2023 4:42 PM, Michael Niedermayer wrote:
> > > > > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > > > > ---
> > > > > libavcodec/snowenc.c | 10 +++++++++-
> > > > > 1 file changed, 9 insertions(+), 1 deletion(-)
> > > > >
> > > > > diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c
> > > > > index 658684c575..5fb5906ed8 100644
> > > > > --- a/libavcodec/snowenc.c
> > > > > +++ b/libavcodec/snowenc.c
> > > > > @@ -26,6 +26,7 @@
> > > > > #include "avcodec.h"
> > > > > #include "codec_internal.h"
> > > > > #include "encode.h"
> > > > > +#include "internal.h" //For AVCodecInternal.recon_frame
> > > > > #include "me_cmp.h"
> > > > > #include "packet_internal.h"
> > > > > #include "snow_dwt.h"
> > > > > @@ -1576,6 +1577,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
> > > > > {
> > > > > SnowContext *s = avctx->priv_data;
> > > > > RangeCoder * const c= &s->c;
> > > > > + AVCodecInternal *avci = avctx->internal;
> > > > > AVFrame *pic;
> > > > > const int width= s->avctx->width;
> > > > > const int height= s->avctx->height;
> > > > > @@ -1877,6 +1879,10 @@ redo_frame:
> > > > > s->encoding_error,
> > > > > (s->avctx->flags&AV_CODEC_FLAG_PSNR) ? SNOW_MAX_PLANES : 0,
> > > > > s->current_picture->pict_type);
> > > > > + if (s->avctx->flags & AV_CODEC_FLAG_RECON_FRAME) {
> > > > > + av_frame_unref(avci->recon_frame);
> > > > > + av_frame_ref(avci->recon_frame, s->current_picture);
> > > > > + }
> > > > > pkt->size = ff_rac_terminate(c, 0);
> > > > > if (s->current_picture->key_frame)
> > > > > @@ -1934,7 +1940,9 @@ const FFCodec ff_snow_encoder = {
> > > > > CODEC_LONG_NAME("Snow"),
> > > > > .p.type = AVMEDIA_TYPE_VIDEO,
> > > > > .p.id = AV_CODEC_ID_SNOW,
> > > > > - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
> > > > > + .p.capabilities = AV_CODEC_CAP_DR1 |
> > > > > + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE |
> > > > > + AV_CODEC_CAP_ENCODER_RECON_FRAME,
> > > > > .priv_data_size = sizeof(SnowContext),
> > > > > .init = encode_init,
> > > > > FF_CODEC_ENCODE_CB(encode_frame),
> > > >
> > > > Testing with the tool from https://git.khirnov.net/libav.git/commit/?h=recon&id=d78e17840347abfe10b2bc7e789c60665de56e1f
> > > > (Which i hope will be upstreamed eventually) i get
> > > >
> > > > $ tools/enc_recon_frame_test input.y4m snow flags=+bitexact 10
> > > > Checksum mismatch in frame ts=0, plane 0
> > >
> > > I cannot replicate this, using matrixbench and above command line i get no
> > > mismatches, where can i find the input.y4m you used ?
> >
> > It was https://0x0.st/sfRh.y4m
> >
> > >
> > > also would be nice if this tool would write a image showing the difference
> > >
> > > thx
> > >
> > > >
> > > > I don't know if this really matters for snow (is it mean to be bitexact?),
> > > > but it seems the very first frame returned by the reconstructed frame API is
> > > > not the same as the one output by the snow decoder. The rest seem to match,
> > > > though.
> > >
> > > This sounds rather strange, the first frame would be used as reference for
> > > motion compensation so the subsequent frames matching after a mismatch is
> > > "surprising"
> >
> > I tried other supported encoders like libx264 and librav1e and none of them
> > report mismatches.
>
> bugs
> ill send a patchset
will apply the fix as well as these 3 patches here
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
it is not once nor twice but times without number that the same ideas make
their appearance in the world. -- Aristotle
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
[-- Attachment #2: Type: text/plain, Size: 251 bytes --]
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 8+ messages in thread