[FFmpeg-devel] [PATCH]lavc/mpegvideo_enc: Do not write an extra RST tag after final jpeg slice
Michael Niedermayer
michael at niedermayer.cc
Tue Jan 21 00:34:45 EET 2020
On Mon, Jan 20, 2020 at 11:15:31PM +0100, Carl Eugen Hoyos wrote:
> Am Mo., 20. Jan. 2020 um 22:51 Uhr schrieb Michael Niedermayer
> <michael at niedermayer.cc>:
> >
> > On Mon, Jan 20, 2020 at 12:54:21AM +0100, Carl Eugen Hoyos wrote:
> > > Hi!
> > >
> > > Attached patch fixes ticket #8412.
> > >
> > > Please comment, Carl Eugen
> >
> > > mpegvideo_enc.c | 7 ++++---
> > > 1 file changed, 4 insertions(+), 3 deletions(-)
> > > 73d8636d0dba4f02cf1697b622c97945d738f06f 0001-lavc-mpegvideo_enc-Do-not-write-an-extra-RST-tag-aft.patch
> > > From 7f62ffa46f9264c1fc7854def8467816e0173883 Mon Sep 17 00:00:00 2001
> > > From: Carl Eugen Hoyos <ceffmpeg at gmail.com>
> > > Date: Mon, 20 Jan 2020 00:51:33 +0100
> > > Subject: [PATCH] lavc/mpegvideo_enc: Do not write an extra RST tag after final
> > > jpeg slice.
> > >
> > > Fixes ticket #8412.
> > > ---
> > > libavcodec/mpegvideo_enc.c | 7 ++++---
> > > 1 file changed, 4 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
> > > index 96f5b4a666..fc1c46fee7 100644
> > > --- a/libavcodec/mpegvideo_enc.c
> > > +++ b/libavcodec/mpegvideo_enc.c
> > > @@ -3566,8 +3566,9 @@ static void merge_context_after_me(MpegEncContext *dst, MpegEncContext *src){
> > > MERGE(me.mb_var_sum_temp);
> > > }
> > >
> > > -static void merge_context_after_encode(MpegEncContext *dst, MpegEncContext *src){
> > > +static void merge_context_after_encode(MpegEncContext *dst, MpegEncContext *src, int last){
> > > int i;
> > > + int put_bits = put_bits_count(&src->pb) - (src->out_format == FMT_MJPEG && src->avctx->active_thread_type & FF_THREAD_SLICE && last ? 32 : 0);
> > >
> > > MERGE(dct_count[0]); //note, the other dct vars are not part of the context
> > > MERGE(dct_count[1]);
> > > @@ -3594,7 +3595,7 @@ static void merge_context_after_encode(MpegEncContext *dst, MpegEncContext *src)
> > >
> > > av_assert1(put_bits_count(&src->pb) % 8 ==0);
> > > av_assert1(put_bits_count(&dst->pb) % 8 ==0);
> > > - avpriv_copy_bits(&dst->pb, src->pb.buf, put_bits_count(&src->pb));
> > > + avpriv_copy_bits(&dst->pb, src->pb.buf, put_bits);
> > > flush_put_bits(&dst->pb);
> > > }
> > >
> > > @@ -3919,7 +3920,7 @@ static int encode_picture(MpegEncContext *s, int picture_number)
> > > for(i=1; i<context_count; i++){
> > > if (s->pb.buf_end == s->thread_context[i]->pb.buf)
> > > set_put_bits_buffer_size(&s->pb, FFMIN(s->thread_context[i]->pb.buf_end - s->pb.buf, INT_MAX/8-32));
> > > - merge_context_after_encode(s, s->thread_context[i]);
> > > + merge_context_after_encode(s, s->thread_context[i], i == context_count - 1);
> > > }
> > > emms_c();
> > > return 0;
> > > --
> > > 2.23.0
> >
> > this looks a bit unexpected
> > is there a reason why the code that writes the RST is not skipped ?
>
> Sorry if I misunderstand but how would one thread know that it is
> the last one and no RST should be written?
the thread encoding the last (as in bottom right) MB should be the last
slice thread
>
> > if it is doing one too much ?
>
> A final RST is written before EOI, the ticket reporter claims that
> it is one too much.
didnt check the spec but such a last RST feels a bit odd at least
>
> Carl Eugen
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
If you drop bombs on a foreign country and kill a hundred thousand
innocent people, expect your government to call the consequence
"unprovoked inhuman terrorist attacks" and use it to justify dropping
more bombs and killing more people. The technology changed, the idea is old.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20200120/883f37bd/attachment.sig>
More information about the ffmpeg-devel
mailing list