* [FFmpeg-devel] [PATCH 1/2] avcodec/jpeg2000dec: Set sample aspect ratio before getting buffer @ 2022-09-23 15:40 Andreas Rheinhardt 2022-09-23 15:41 ` [FFmpeg-devel] [PATCH 2/2] avcodec/jpeg2000dec: Implement FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM Andreas Rheinhardt 2022-09-23 18:23 ` [FFmpeg-devel] [PATCH 1/2] avcodec/jpeg2000dec: Set sample aspect ratio before getting buffer Tomas Härdin 0 siblings, 2 replies; 7+ messages in thread From: Andreas Rheinhardt @ 2022-09-23 15:40 UTC (permalink / raw) To: ffmpeg-devel; +Cc: Andreas Rheinhardt That way the SAR will be automatically set on the AVFrame. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- If I am not mistaken, then the earlier code would set the sar with a delay of one frame on the returned frames in case there is a sar change mid-stream. But I don't have a sample for this. libavcodec/jpeg2000dec.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c index 7d9661f29f..c3f2a7aa03 100644 --- a/libavcodec/jpeg2000dec.c +++ b/libavcodec/jpeg2000dec.c @@ -2519,6 +2519,10 @@ static int jpeg2000_decode_frame(AVCodecContext *avctx, AVFrame *picture, if (ret = jpeg2000_read_main_headers(s)) goto end; + if (s->sar.num && s->sar.den) + avctx->sample_aspect_ratio = s->sar; + s->sar.num = s->sar.den = 0; + /* get picture buffer */ if ((ret = ff_thread_get_buffer(avctx, picture, 0)) < 0) goto end; @@ -2547,9 +2551,6 @@ static int jpeg2000_decode_frame(AVCodecContext *avctx, AVFrame *picture, if (s->avctx->pix_fmt == AV_PIX_FMT_PAL8) memcpy(picture->data[1], s->palette, 256 * sizeof(uint32_t)); - if (s->sar.num && s->sar.den) - avctx->sample_aspect_ratio = s->sar; - s->sar.num = s->sar.den = 0; return bytestream2_tell(&s->g); -- 2.34.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] 7+ messages in thread
* [FFmpeg-devel] [PATCH 2/2] avcodec/jpeg2000dec: Implement FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM 2022-09-23 15:40 [FFmpeg-devel] [PATCH 1/2] avcodec/jpeg2000dec: Set sample aspect ratio before getting buffer Andreas Rheinhardt @ 2022-09-23 15:41 ` Andreas Rheinhardt 2022-09-23 18:24 ` Tomas Härdin 2022-09-23 18:23 ` [FFmpeg-devel] [PATCH 1/2] avcodec/jpeg2000dec: Set sample aspect ratio before getting buffer Tomas Härdin 1 sibling, 1 reply; 7+ messages in thread From: Andreas Rheinhardt @ 2022-09-23 15:41 UTC (permalink / raw) To: ffmpeg-devel; +Cc: Andreas Rheinhardt This could be improved further by not allocating the buffers that won't be needed lateron in the first place. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/jpeg2000dec.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c index c3f2a7aa03..63a706fbf5 100644 --- a/libavcodec/jpeg2000dec.c +++ b/libavcodec/jpeg2000dec.c @@ -2523,6 +2523,11 @@ static int jpeg2000_decode_frame(AVCodecContext *avctx, AVFrame *picture, avctx->sample_aspect_ratio = s->sar; s->sar.num = s->sar.den = 0; + if (avctx->skip_frame >= AVDISCARD_ALL) { + jpeg2000_dec_cleanup(s); + return 0; + } + /* get picture buffer */ if ((ret = ff_thread_get_buffer(avctx, picture, 0)) < 0) goto end; @@ -2587,4 +2592,5 @@ const FFCodec ff_jpeg2000_decoder = { .p.priv_class = &jpeg2000_class, .p.max_lowres = 5, .p.profiles = NULL_IF_CONFIG_SMALL(ff_jpeg2000_profiles), + .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, }; -- 2.34.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] 7+ messages in thread
* Re: [FFmpeg-devel] [PATCH 2/2] avcodec/jpeg2000dec: Implement FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM 2022-09-23 15:41 ` [FFmpeg-devel] [PATCH 2/2] avcodec/jpeg2000dec: Implement FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM Andreas Rheinhardt @ 2022-09-23 18:24 ` Tomas Härdin 0 siblings, 0 replies; 7+ messages in thread From: Tomas Härdin @ 2022-09-23 18:24 UTC (permalink / raw) To: FFmpeg development discussions and patches fre 2022-09-23 klockan 17:41 +0200 skrev Andreas Rheinhardt: > This could be improved further by not allocating the buffers > that won't be needed lateron in the first place. My parallellization patches do this > > Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> > --- > libavcodec/jpeg2000dec.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c > index c3f2a7aa03..63a706fbf5 100644 > --- a/libavcodec/jpeg2000dec.c > +++ b/libavcodec/jpeg2000dec.c > @@ -2523,6 +2523,11 @@ static int > jpeg2000_decode_frame(AVCodecContext *avctx, AVFrame *picture, > avctx->sample_aspect_ratio = s->sar; > s->sar.num = s->sar.den = 0; > > + if (avctx->skip_frame >= AVDISCARD_ALL) { > + jpeg2000_dec_cleanup(s); > + return 0; > + } > + > /* get picture buffer */ > if ((ret = ff_thread_get_buffer(avctx, picture, 0)) < 0) > goto end; > @@ -2587,4 +2592,5 @@ const FFCodec ff_jpeg2000_decoder = { > .p.priv_class = &jpeg2000_class, > .p.max_lowres = 5, > .p.profiles = NULL_IF_CONFIG_SMALL(ff_jpeg2000_profiles), > + .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, Looks good /Tomas _______________________________________________ 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] 7+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/2] avcodec/jpeg2000dec: Set sample aspect ratio before getting buffer 2022-09-23 15:40 [FFmpeg-devel] [PATCH 1/2] avcodec/jpeg2000dec: Set sample aspect ratio before getting buffer Andreas Rheinhardt 2022-09-23 15:41 ` [FFmpeg-devel] [PATCH 2/2] avcodec/jpeg2000dec: Implement FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM Andreas Rheinhardt @ 2022-09-23 18:23 ` Tomas Härdin 2022-09-23 18:48 ` Andreas Rheinhardt 1 sibling, 1 reply; 7+ messages in thread From: Tomas Härdin @ 2022-09-23 18:23 UTC (permalink / raw) To: FFmpeg development discussions and patches fre 2022-09-23 klockan 17:40 +0200 skrev Andreas Rheinhardt: > That way the SAR will be automatically set on the AVFrame. > > Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> > --- > If I am not mistaken, then the earlier code would set the sar > with a delay of one frame on the returned frames in case > there is a sar change mid-stream. But I don't have a sample > for this. > > libavcodec/jpeg2000dec.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c > index 7d9661f29f..c3f2a7aa03 100644 > --- a/libavcodec/jpeg2000dec.c > +++ b/libavcodec/jpeg2000dec.c > @@ -2519,6 +2519,10 @@ static int > jpeg2000_decode_frame(AVCodecContext *avctx, AVFrame *picture, > if (ret = jpeg2000_read_main_headers(s)) > goto end; > > + if (s->sar.num && s->sar.den) > + avctx->sample_aspect_ratio = s->sar; > + s->sar.num = s->sar.den = 0; > + > /* get picture buffer */ > if ((ret = ff_thread_get_buffer(avctx, picture, 0)) < 0) > goto end; > @@ -2547,9 +2551,6 @@ static int jpeg2000_decode_frame(AVCodecContext > *avctx, AVFrame *picture, > > if (s->avctx->pix_fmt == AV_PIX_FMT_PAL8) > memcpy(picture->data[1], s->palette, 256 * > sizeof(uint32_t)); > - if (s->sar.num && s->sar.den) > - avctx->sample_aspect_ratio = s->sar; > - s->sar.num = s->sar.den = 0; I suspect not doing this is what caused my simple hack to not work when ff_thread_get_buffer() was skipped. Looks OK, passes FATE. /Tomas _______________________________________________ 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] 7+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/2] avcodec/jpeg2000dec: Set sample aspect ratio before getting buffer 2022-09-23 18:23 ` [FFmpeg-devel] [PATCH 1/2] avcodec/jpeg2000dec: Set sample aspect ratio before getting buffer Tomas Härdin @ 2022-09-23 18:48 ` Andreas Rheinhardt 2022-09-23 19:36 ` Tomas Härdin 0 siblings, 1 reply; 7+ messages in thread From: Andreas Rheinhardt @ 2022-09-23 18:48 UTC (permalink / raw) To: ffmpeg-devel Tomas Härdin: > fre 2022-09-23 klockan 17:40 +0200 skrev Andreas Rheinhardt: >> That way the SAR will be automatically set on the AVFrame. >> >> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> >> --- >> If I am not mistaken, then the earlier code would set the sar >> with a delay of one frame on the returned frames in case >> there is a sar change mid-stream. But I don't have a sample >> for this. >> >> libavcodec/jpeg2000dec.c | 7 ++++--- >> 1 file changed, 4 insertions(+), 3 deletions(-) >> >> diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c >> index 7d9661f29f..c3f2a7aa03 100644 >> --- a/libavcodec/jpeg2000dec.c >> +++ b/libavcodec/jpeg2000dec.c >> @@ -2519,6 +2519,10 @@ static int >> jpeg2000_decode_frame(AVCodecContext *avctx, AVFrame *picture, >> if (ret = jpeg2000_read_main_headers(s)) >> goto end; >> >> + if (s->sar.num && s->sar.den) >> + avctx->sample_aspect_ratio = s->sar; >> + s->sar.num = s->sar.den = 0; >> + >> /* get picture buffer */ >> if ((ret = ff_thread_get_buffer(avctx, picture, 0)) < 0) >> goto end; >> @@ -2547,9 +2551,6 @@ static int jpeg2000_decode_frame(AVCodecContext >> *avctx, AVFrame *picture, >> >> if (s->avctx->pix_fmt == AV_PIX_FMT_PAL8) >> memcpy(picture->data[1], s->palette, 256 * >> sizeof(uint32_t)); >> - if (s->sar.num && s->sar.den) >> - avctx->sample_aspect_ratio = s->sar; >> - s->sar.num = s->sar.den = 0; > > I suspect not doing this is what caused my simple hack to not work when > ff_thread_get_buffer() was skipped. Looks OK, passes FATE. > FYI: Patch two passes FATE even without patch one. In what way did your simple hack not work when ff_thread_get_buffer() is skipped? - Andreas _______________________________________________ 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] 7+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/2] avcodec/jpeg2000dec: Set sample aspect ratio before getting buffer 2022-09-23 18:48 ` Andreas Rheinhardt @ 2022-09-23 19:36 ` Tomas Härdin 2022-09-23 19:56 ` Andreas Rheinhardt 0 siblings, 1 reply; 7+ messages in thread From: Tomas Härdin @ 2022-09-23 19:36 UTC (permalink / raw) To: FFmpeg development discussions and patches [-- Attachment #1: Type: text/plain, Size: 2248 bytes --] fre 2022-09-23 klockan 20:48 +0200 skrev Andreas Rheinhardt: > Tomas Härdin: > > fre 2022-09-23 klockan 17:40 +0200 skrev Andreas Rheinhardt: > > > That way the SAR will be automatically set on the AVFrame. > > > > > > Signed-off-by: Andreas Rheinhardt > > > <andreas.rheinhardt@outlook.com> > > > --- > > > If I am not mistaken, then the earlier code would set the sar > > > with a delay of one frame on the returned frames in case > > > there is a sar change mid-stream. But I don't have a sample > > > for this. > > > > > > libavcodec/jpeg2000dec.c | 7 ++++--- > > > 1 file changed, 4 insertions(+), 3 deletions(-) > > > > > > diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c > > > index 7d9661f29f..c3f2a7aa03 100644 > > > --- a/libavcodec/jpeg2000dec.c > > > +++ b/libavcodec/jpeg2000dec.c > > > @@ -2519,6 +2519,10 @@ static int > > > jpeg2000_decode_frame(AVCodecContext *avctx, AVFrame *picture, > > > if (ret = jpeg2000_read_main_headers(s)) > > > goto end; > > > > > > + if (s->sar.num && s->sar.den) > > > + avctx->sample_aspect_ratio = s->sar; > > > + s->sar.num = s->sar.den = 0; > > > + > > > /* get picture buffer */ > > > if ((ret = ff_thread_get_buffer(avctx, picture, 0)) < 0) > > > goto end; > > > @@ -2547,9 +2551,6 @@ static int > > > jpeg2000_decode_frame(AVCodecContext > > > *avctx, AVFrame *picture, > > > > > > if (s->avctx->pix_fmt == AV_PIX_FMT_PAL8) > > > memcpy(picture->data[1], s->palette, 256 * > > > sizeof(uint32_t)); > > > - if (s->sar.num && s->sar.den) > > > - avctx->sample_aspect_ratio = s->sar; > > > - s->sar.num = s->sar.den = 0; > > > > I suspect not doing this is what caused my simple hack to not work > > when > > ff_thread_get_buffer() was skipped. Looks OK, passes FATE. > > > > FYI: Patch two passes FATE even without patch one. In what way did > your > simple hack not work when ff_thread_get_buffer() is skipped? I had it like patch attached. I suspect the reason it didn't work is because it sets *got_frame. If I run it then I get Assertion frame->buf[0] failed at libavcodec/decode.c:502 Avbruten (SIGABRT) /Tomas [-- Attachment #2: 0001-HACKHACK.patch --] [-- Type: text/x-patch, Size: 1266 bytes --] From e5ca5e47053b7d7ba130eec01576df041196d5d4 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Date: Fri, 23 Sep 2022 17:41:41 +0200 Subject: [PATCH] HACKHACK --- libavcodec/jpeg2000dec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c index 7d9661f29f..8cab440d13 100644 --- a/libavcodec/jpeg2000dec.c +++ b/libavcodec/jpeg2000dec.c @@ -2519,6 +2519,7 @@ static int jpeg2000_decode_frame(AVCodecContext *avctx, AVFrame *picture, if (ret = jpeg2000_read_main_headers(s)) goto end; + if (avctx->skip_frame < AVDISCARD_ALL) { /* get picture buffer */ if ((ret = ff_thread_get_buffer(avctx, picture, 0)) < 0) goto end; @@ -2540,6 +2541,7 @@ static int jpeg2000_decode_frame(AVCodecContext *avctx, AVFrame *picture, } avctx->execute2(avctx, jpeg2000_decode_tile, picture, NULL, s->numXtiles * s->numYtiles); + } jpeg2000_dec_cleanup(s); @@ -2586,4 +2588,5 @@ const FFCodec ff_jpeg2000_decoder = { .p.priv_class = &jpeg2000_class, .p.max_lowres = 5, .p.profiles = NULL_IF_CONFIG_SMALL(ff_jpeg2000_profiles), + .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, }; -- 2.30.2 [-- Attachment #3: 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] 7+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/2] avcodec/jpeg2000dec: Set sample aspect ratio before getting buffer 2022-09-23 19:36 ` Tomas Härdin @ 2022-09-23 19:56 ` Andreas Rheinhardt 0 siblings, 0 replies; 7+ messages in thread From: Andreas Rheinhardt @ 2022-09-23 19:56 UTC (permalink / raw) To: ffmpeg-devel Tomas Härdin: > fre 2022-09-23 klockan 20:48 +0200 skrev Andreas Rheinhardt: >> Tomas Härdin: >>> fre 2022-09-23 klockan 17:40 +0200 skrev Andreas Rheinhardt: >>>> That way the SAR will be automatically set on the AVFrame. >>>> >>>> Signed-off-by: Andreas Rheinhardt >>>> <andreas.rheinhardt@outlook.com> >>>> --- >>>> If I am not mistaken, then the earlier code would set the sar >>>> with a delay of one frame on the returned frames in case >>>> there is a sar change mid-stream. But I don't have a sample >>>> for this. >>>> >>>> libavcodec/jpeg2000dec.c | 7 ++++--- >>>> 1 file changed, 4 insertions(+), 3 deletions(-) >>>> >>>> diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c >>>> index 7d9661f29f..c3f2a7aa03 100644 >>>> --- a/libavcodec/jpeg2000dec.c >>>> +++ b/libavcodec/jpeg2000dec.c >>>> @@ -2519,6 +2519,10 @@ static int >>>> jpeg2000_decode_frame(AVCodecContext *avctx, AVFrame *picture, >>>> if (ret = jpeg2000_read_main_headers(s)) >>>> goto end; >>>> >>>> + if (s->sar.num && s->sar.den) >>>> + avctx->sample_aspect_ratio = s->sar; >>>> + s->sar.num = s->sar.den = 0; >>>> + >>>> /* get picture buffer */ >>>> if ((ret = ff_thread_get_buffer(avctx, picture, 0)) < 0) >>>> goto end; >>>> @@ -2547,9 +2551,6 @@ static int >>>> jpeg2000_decode_frame(AVCodecContext >>>> *avctx, AVFrame *picture, >>>> >>>> if (s->avctx->pix_fmt == AV_PIX_FMT_PAL8) >>>> memcpy(picture->data[1], s->palette, 256 * >>>> sizeof(uint32_t)); >>>> - if (s->sar.num && s->sar.den) >>>> - avctx->sample_aspect_ratio = s->sar; >>>> - s->sar.num = s->sar.den = 0; >>> >>> I suspect not doing this is what caused my simple hack to not work >>> when >>> ff_thread_get_buffer() was skipped. Looks OK, passes FATE. >>> >> >> FYI: Patch two passes FATE even without patch one. In what way did >> your >> simple hack not work when ff_thread_get_buffer() is skipped? > > I had it like patch attached. I suspect the reason it didn't work is > because it sets *got_frame. If I run it then I get > > Assertion frame->buf[0] failed at libavcodec/decode.c:502 > Avbruten (SIGABRT) > > /Tomas > Yeah, that's not how it's supposed to work. Will apply my patches. Thanks for the review. - Andreas _______________________________________________ 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] 7+ messages in thread
end of thread, other threads:[~2022-09-23 19:56 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-09-23 15:40 [FFmpeg-devel] [PATCH 1/2] avcodec/jpeg2000dec: Set sample aspect ratio before getting buffer Andreas Rheinhardt 2022-09-23 15:41 ` [FFmpeg-devel] [PATCH 2/2] avcodec/jpeg2000dec: Implement FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM Andreas Rheinhardt 2022-09-23 18:24 ` Tomas Härdin 2022-09-23 18:23 ` [FFmpeg-devel] [PATCH 1/2] avcodec/jpeg2000dec: Set sample aspect ratio before getting buffer Tomas Härdin 2022-09-23 18:48 ` Andreas Rheinhardt 2022-09-23 19:36 ` Tomas Härdin 2022-09-23 19:56 ` Andreas Rheinhardt
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git